The MU forums have moved to WordPress.org

get_currentuserinfo error (2 posts)

  1. jasontower
    Member
    Posted 15 years ago #

    I want to show some info of current user, so I save the example code in a php file under domain root folder:
    <?php global $current_user;
    get_currentuserinfo();
    echo 'Username: ' . $current_user->user_login . "\n";
    echo 'User email: ' . $current_user->user_email . "\n";
    echo 'User level: ' . $current_user->user_level . "\n";
    echo 'User first name: ' . $current_user->user_firstname . "\n";
    echo 'User last name: ' . $current_user->user_lastname . "\n";
    echo 'User display name: ' . $current_user->display_name . "\n";
    echo 'User ID: ' . $current_user->ID . "\n";
    ?>
    but when load that page, nothing happens but a blank page.
    How to solve it?
    Thanks!

  2. dsader
    Member
    Posted 15 years ago #

    Try calling the code from a theme's index.php instead.

    WPMU needs to be loaded first - and calling the file directly as you've tried will do nothing.

    When calling the file you've made above directly, no other wpmu files will be loaded, so how will it know what $current_user is? Makes sense doesn't it?

    If you are going to add the code somewhere, add it to a theme's files directly or a plugin which hooks into them.

About this Topic

  • Started 15 years ago by jasontower
  • Latest reply from dsader