• Resolved daverogers

    (@daverogers)


    Hi
    I am trying to pull the user id of the person logged in so I can display there user avatar on the home page but cannot seem to get this working. Any Ideas. I am using this in a php widget

Viewing 6 replies - 1 through 6 (of 6 total)
  • You should be able to just use something like

    $current_user = wp_get_current_user();
    $output .= get_avatar( $current_user->ID, 32 );
    return $output;

    The Emporium eShop theme (currently still in beta) includes a custom Login Widget that displays the user avatar. You might want to try downloading that theme and having a look in /library/login-widget.php.

    Thread Starter daverogers

    (@daverogers)

    so ie

    <?php
    $current_user = wp_get_current_user();
    $output .= get_avatar( $current_user->ID, 32 )
    return $output;
    ?>

    Im a bit of a noob at this. BTW Nice themes

    Sort of. It really depends upon what you’re doing within this widget and how it’s set up to generate the final content. The widget I created pours everything into a $output variable which is then returned and echoed to the screen. A simpler method would be to just use:

    <?php
    $current_user = wp_get_current_user();
    echo get_avatar( $current_user->ID, 32 );
    ?>

    BTW Nice themes

    Thank you. 🙂

    Thread Starter daverogers

    (@daverogers)

    Sorry I might not have been clear. Im not creating the widget. What I am doing is making an image link <img src=”images/users/<user id here>.jpg”>
    I am using a widget which allows php

    Thread Starter daverogers

    (@daverogers)

    i cannot thank you enough
    it works perfectly

    Excellent! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Pulling user ID’ is closed to new replies.