Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to link the avatar picture to his/her profile page


  • riseUp
    Participant

    @mosesyoon

    Hello.

    When you go to the homepage, http://www.ymphony.com, you will notice that, when you click on the avatar picture,the site will lead the user to the list of posts that the avatar (user) created.

    However, I would like the avatar picture to link to its profile page.

    Could anybody kindly assist me in this? Thank you.

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

  • @mcuk
    Participant

    @mcuk

    Hi @mosesyoon,

    If you find the file that is creating the avatar picture, wrapping the avatar code in something like this might work:

    <a href="<?php bp_displayed_user_link(); ?>"> AVATAR PICTURE FUNCTION/CODE HERE </a>

    Example below is from the buddypress cover-image-header.php file. Once you have found the file, ensure that you copy it into your child theme before making modifications.

    <div id="item-header-avatar">
    	<a href="<?php bp_displayed_user_link(); ?>">
    		<?php bp_displayed_user_avatar( 'type=full' ); ?>
    	</a>
    </div>

    (not really familiar with the blog side as i don’t use it nor do i know your site setup, so this approach is more a shot in the dark)


    shanebp
    Moderator

    @shanebp

    bp_displayed_user_link() only works when viewing profile pages.

    You need to open the file that calls the posts loop on your front page.
    In that loop you’ll find a call to the post author.
    And the creation of a link.
    In that link, change the href to bp_core_get_user_domain( $post->post_author );


    riseUp
    Participant

    @mosesyoon

    Hi all,

    Didn’t seem to work. This is what I did.

    I pulled up the following code in functions.php:

    
    //* Add post image above post title
    add_action( 'genesis_entry_header', 'streamline_post_image', 1 );
    function streamline_post_image() {
    
    	if ( is_page() || ! genesis_get_option( 'content_archive_thumbnail' ) )
    		return;
    	
    	if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => genesis_get_option( 'image_size' ) ) ) ) {
    		printf( '<a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
    	}
    	
    }

    …and then tried to add bp_core_get_user_domain( $post->post_author ); like that resulted in this:

    //* Add post image above post title
    add_action( 'genesis_entry_header', 'streamline_post_image', 1 );
    function streamline_post_image() {
    
    	if ( is_page() || ! genesis_get_option( 'content_archive_thumbnail' ) )
    		return;
    	
    	if ( $image = genesis_get_image( array( 'format' => 'url', 'size' => genesis_get_option( 'image_size' ) ) ) ) {
    		printf( '<a href="bp_core_get_user_domain(">post_author ); rel="bookmark"><img src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
    	}
    	
    }
    

    …however, when I clicked on the avatar picture, the above code update did not lead me to the user’s profile page. Rather, it continued to show the list of posts the author created in the past.

    Am I doing this right? Can somebody continue to assist please? Thanks!


    @mcuk
    Participant

    @mcuk

    Hi @mosesyoon,

    In the second code of yours above I think you may be missing an opening bracket on the printf line. Btw use the code button when posting on here, so it’s easier to read.

    Anyway maybe try this:

    function streamline_post_image() {
    
    if ( is_page() || ! genesis_get_option( ‘content_archive_thumbnail’ ) )
    return;
    
    if ( $image = genesis_get_image( array( ‘format’ => ‘url’, ‘size’ => genesis_get_option( ‘image_size’ ) ) ) ) {
    printf( ‘%s‘, bp_core_get_user_domain( $post->post_author ), $image, the_title_attribute( ‘echo=0’ ) );
    }
    
    }
    add_action( ‘genesis_entry_header’, ‘streamline_post_image’, 1 );

    riseUp
    Participant

    @mosesyoon

    Hm….when I copied and pasted your suggested code, I get the following message:

    Parse error: syntax error, unexpected ‘=’ in /home/content/p3pnexwpnas06_data03/32/3122732/html/wp-content/themes/streamline-pro/functions.php on line 107

    What do you think? How do you think I should adjust this code? Thank you!


    @mcuk
    Participant

    @mcuk

    what is on line 107 of your functions.php file? is it the code above? if it is, try and replace it with ==


    riseUp
    Participant

    @mosesyoon

    Yes, it is the code above.

    I wasn’t sure what you meant when you said “try and replace it with ==. Can you please clarify? Thanks.


    @mcuk
    Participant

    @mcuk

    I was just taking a shot in the dark, that if line 107 was the one :

    if ( $image = genesis_get_image( array( ‘format’ => ‘url’, ‘size’ => genesis_get_option( ‘image_size’ ) ) ) ) {

    then change the = to ==.

    But the problem maybe something incorrect prior to the = sign. A missing semicolon, bracket etc. Does the function work properly in its original state (i.e. before alterations were made?).

    May be useful to ask your theme support as to where the link from Shane should go, as I’m not familiar with it.


    riseUp
    Participant

    @mosesyoon

    Hi @shanebp,

    I’ve been struggling with this a bit…as I was looking at your reply to me from the beginning of this discussion thread. I may need a little more explicit instruction if possible as I wasn’t following your instructions. Could you provide a bit more info here? Thank you!


    shanebp
    Moderator

    @shanebp

    Did you try:

    printf( '<a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a>', bp_core_get_user_domain( $post->post_author ), $image, the_title_attribute( 'echo=0' ) );


    riseUp
    Participant

    @mosesyoon

    Yes, @shanebp, I just tried this and there was no change – when I click on the avatar picture, I am taken to all the posts that I made (archive) rather than my profile.

    Do you have any other suggestions? Thank you.


    shanebp
    Moderator

    @shanebp

    And if you click on the post image, where do you go?


    riseUp
    Participant

    @mosesyoon

    Hi – I go to a page that lists all of the posts that “riseUp” created. Like this:

    http://ymphony.com/author/mosesyoon/


    shanebp
    Moderator

    @shanebp

    None of those posts have images – so how are you clicking on the post image?
    Create a post with an image in it – then click it.


    riseUp
    Participant

    @mosesyoon

    @shanebp, you don’t see a face for each post? That’s the image I’m referring to.


    shanebp
    Moderator

    @shanebp

    That’s an avatar, not a post image.
    The function you pasted above streamline_post_image() deals with post images, not avatars – correct?
    Try adding a post image to a post and see if it has a link to the author profile.
    Then find the code that calls the avatar and use the same process to change the avatar link.
    As I suggested in my first post in this thread.


    riseUp
    Participant

    @mosesyoon

    Hi @shanebp,

    I’m still trying to figure this out after a week of trial and error. Let’s step back a little for a second if we may…

    So, on http://www.ymphony.com, when a user clicks on a post’s avatar, I’d like the site to direct the user to the avatar’s profile page. The profile page is created by Buddy Press.

    It doesn’t seem like the following is relevant because I think you assumed that it was for a post:

    printf( ‘%s‘, bp_core_get_user_domain( $post->post_author ), $image, the_title_attribute( ‘echo=0’ ) );

    Correct?

    If the link is on the avatar, what code should I place and where?

    This has been a bit challenging but thank you for hanging in there with me!


    shanebp
    Moderator

    @shanebp

    what code should I place and where?

    I’ve provided the code to use.
    And explained that you need to find the code that displays the avatar on post pages – it’s somewhere in your theme.


    riseUp
    Participant

    @mosesyoon

    @shanebp, I’ll definite take a look carefully. Thank you!

Viewing 19 replies - 1 through 19 (of 19 total)
  • You must be logged in to reply to this topic.
Skip to toolbar