• I’ve just upgraded to WP1.5 with a new template. Unfortunately, I’m having some problems with the variables returned by get_currentuserinfo() in the comments template.

    This is the code I’m using:

    <?php get_currentuserinfo(); ?>
    <?php if ( $user_ID ) : ?>

    Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>">Logout &raquo;</a>

    <input type="hidden" name="author" value="<?php echo $user_identity; ?>;" />
    <input type="hidden" name="email" value="<?php echo $user_email; ?>" />
    <input type="hidden" name="url" value="<?php echo $user_url; ?>" />

    <?php else : ?>

    The problem is that $user_identity is returned correctly, but $user_url and $user_email are empty. (This means that while I’m logged in, I can’t comment because those fields are required.)

    I can’t for the life of me work out what’s wrong. Any suggestions?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try the user variables without calling get_currentuserinfo(). The comments_template() function sets these variables as global, and apparently running get_currentuserinfo() as you are is resetting them. If that doesn’t do it, try setting them to global before calling the function.

    Thread Starter robcorr

    (@robcorr)

    I added get_currentuserinfo() because the same thing was happening without calling it.

    How do I set them to global?

    <?php
    global $user_identity, $user_url, $user_email;
    get_currentuserinfo();
    ?>

    Thread Starter robcorr

    (@robcorr)

    That worked a treat! Thanks for your help.

    I don’t suppose you could send me a copy of your comment.php that utilizes this? I am having a terrible time trying to get comments to work right; when the person is logged in, the email and url don’t get attached. I would prefer that they either attach or don’t show an invalid link of “https:///&#8221;.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problems with get_currentuserinfo(), $user_email and $user_url’ is closed to new replies.