0

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.

11
  • show me some more code. what did you mean crash? Commented Mar 24, 2013 at 7:33
  • my whole site becomes blank. Commented Mar 24, 2013 at 7:33
  • did you check the html source? Commented Mar 24, 2013 at 7:37
  • Where exactly are you adding this plugin? Commented Mar 24, 2013 at 7:38
  • 1
    i am assuming that site gone white is not crashing but there is error in the script. Please check the error log. You might find some help there. Commented Mar 24, 2013 at 7:39

1 Answer 1

1

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');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.