Forums

[resolved] Echo logged-in user's site URL (3 posts)

  1. RyanWilliams
    Member
    Posted 3 years ago #

    Heya,

    I have a comment form for logged in users that basically looks the same as the one shown to regular visitors, but has the fields disabled and thus basically there for cosmetic reasons.

    The code I have is:

    <div class="your_name">
    	<label for="author">Logged In As:</label>
    	<input class="text" id="author" name="author" type="text" disabled="disabled" value="<?php echo $user_identity; ?>" tabindex="1" />
    </div>
    <div class="website">
    	<label for="url">Website:</label>
    	<input class="text" id="url" name="url" type="text" disabled="disabled" value="<?php echo $user_url; ?>" tabindex="2" />
    </div>

    This is essentially fine, but the variable I'm using to try and echo the user's profile URL does nothing. Does anyone know what the correct variable to use here would be?

  2. Otto
    Tech Ninja
    Posted 3 years ago #

    I don't like using globals that way. It's too hit or miss.

    $user=wp_get_current_user();
    echo $user->display_name;
    echo $user->user_url;

    Much better way to go.

  3. RyanWilliams
    Member
    Posted 3 years ago #

    Thanks Otto, that does the trick beautifully! :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.