Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter kmvan

    (@kmvan)

    to use the function of is_home() that it works.
    the is_user_logged_in doesn’t work, why?

    Thread Starter kmvan

    (@kmvan)

    now i write the is_user_logged_in() in the function,it works.but the outside.

    Thread Starter kmvan

    (@kmvan)

    yes.i had read. but nothing found…

    What do you mean by plugin page? functions.php?

    Thread Starter kmvan

    (@kmvan)

    plugin page means the my-plugin-name.php.
    for example:
    my-plugin-name.php:

    <?php
    /*
    Plugin Name: my plugin
    Plugin URI: ....
    ...
    */
    if(is_user_logged_in()){
     function example(){
      ...
     }
    }
    ?>

    like this, it shows me a error: the is_user_logged_in() is undefined.
    but like this:

    <?php
    /*
    Plugin Name: my plugin
    Plugin URI: ....
    ...
    */
    function example(){
     if(is_user_logged_in()){
      ...
     }
    }
    ?>

    it works!
    can get me?

    I think it’s because is_user_logged_in() is located in wp-includes/pluggable.php and if you open the file it says at the top:

    These functions can be replaced via plugins. If plugins do not redefine these functions, then these will be used instead.

    ie, my-plugin-name.php is been loaded before pluggable.php.

    Thread Starter kmvan

    (@kmvan)

    oh, I think ur right!
    thank u.:)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘In the plugin page, I can't use the function of is_user_logged_in()?’ is closed to new replies.