Page 1 of 1

HOW display logged user avatar in a certain page of WP

Posted: Fri Jan 20, 2017 10:07 pm
by skynet969
Hi!

Only a question.
Did is possible display a logged user avatar in a certain page, post of part in WP by php code?
I want insert user avatar into thirdy part login widget like this:
Cattura.PNG
Cattura.PNG (13.42 KiB) Viewed 12862 times
Thank in advance.

Re: HOW display logged user avatar in a certain page of WP

Posted: Fri Jan 20, 2017 10:36 pm
by axew3
yes, but it depend from where the avatar come from.
I suppose you are using the phpBB WordPress integration?

By the way if you want to display an avatar into a login widget, it isn't complicate as you just need to display avatar for the current user, so the code will look like this, just to be sure will work on any situation:

Code: Select all

$current_user = wp_get_current_user();
    echo get_avatar( $current_user->ID, 32 ); 
Are you using the integration plugin?

'32' is the size in px of the avatar to display.

Re: HOW display logged user avatar in a certain page of WP

Posted: Fri Jan 20, 2017 10:49 pm
by skynet969
Sorry, I forget this info.

Yes, I use integration plugin, and in my pic you can view the results of get_avatar command: it' blank.

The phpBB avatar overwrite option in WP is actived and display avatar in WP in shift On.

Re: HOW display logged user avatar in a certain page of WP

Posted: Fri Jan 20, 2017 11:01 pm
by skynet969
Escuse me for double reply.

Merge, if you want.

My pieze of code is look like this:

Code: Select all

<div class="logged-in"> <? echo get_avatar ( $id_or_email, $size = '20' ); ?> <?php echo $link_with_username;?> | <a href="<?php echo wp_logout_url( $logout_redirect_page ); ?>" title="<?php _e('Logout','login-sidebar-widget');?>"><?php _e('Logout','login-sidebar-widget');?></a></div>

Re: HOW display logged user avatar in a certain page of WP

Posted: Fri Jan 20, 2017 11:29 pm
by axew3
are you using the integration plugin? This post moved to WordPress forum.

Code: Select all

<? echo get_avatar ( $id_or_email, $size = '20' ); ?>
you need to put this where you need to output the avatar.

Re: HOW display logged user avatar in a certain page of WP

Posted: Wed Oct 10, 2018 11:57 am
by Nicki
Thaks :)