Reputation: 626
I am new to plugin development in wordpress.
I want to add just a simple html code to wp_footer using action hook I just learned from wordpress codex.
<?php
/*
Plugin Name: test
Plugin URI: http://mysite.com
Description: test
Version: 1.0
Author: me
Author URI: http://mysite.com
*/
function addbar(){
echo '<div id="cbar">';
echo '</div>';
}
if ( is_user_logged_in() ){
add_action('wp_footer','addbar');
} else {
}
?>
This code does not works , it crashes my site.
Upvotes: 0
Views: 126
Reputation:
i think as this function is in pluggable.php, that the function doesn't exist when the plugin is activated. This should mean that you just have to delay the loading of your logic.
function addbar(){
if(is_user_logged_in()){
echo '<div id="cbar">';
echo '</div>';
}
}
add_action('wp_footer','addbar');
Upvotes: 1