HOW display logged user avatar in a certain page of WP

skynet969
User w
User w
Posts: 8
Joined: Fri Jan 20, 2017 9:43 pm

HOW display logged user avatar in a certain page of WP

Post 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 14334 times
Thank in advance.
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

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

Post 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.
skynet969
User w
User w
Posts: 8
Joined: Fri Jan 20, 2017 9:43 pm

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

Post 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.
skynet969
User w
User w
Posts: 8
Joined: Fri Jan 20, 2017 9:43 pm

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

Post 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>
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

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

Post 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.
Nicki
Posts: 1
Joined: Wed Oct 10, 2018 11:55 am

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

Post by Nicki »

Thaks :)
Post Reply