Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get user_nicename to display a link on post.php?

  • Hello,

    I would like to display a link to the profiles of my WordPress website on the post.php file, just below the username and avatar.

    I tried a code that I found in the profile.php file : <?php echo get_user_display_name( $user->ID ); ?>

    But I can’t even make it work. Is it possible to get the Worpress user nicename to create this link? I did a complete WP/BBpress integration…

    Thanks a lot for your help

Viewing 8 replies - 1 through 8 (of 8 total)
  • <?php bb_profile_link( array( 'id' => $user->ID, 'text' => get_user_display_name( $user->ID ) ) ); ?>

    I’d guess… not really sure on the context where you’re putting it though, so I can’t really test

    Thanks a lot for your help!

    Actually it displays a link “view your profile” as you can see here : http://www.spleenarcana.com/forums/topic/what-are-you-listening-to-right-now

    But I explained it in a bad way because I’d like a link to my WordPress profile pages, for example :

    http://www.spleenarcana.com/members/admin/ (where “admin” is the nicename and I changed “author” for members)

    Do you think it’s possible?

    Any other idea maybe?

    Actually, it would be really great if I could use WordPress profile page instead of BBpress profile page, you know? Because on my WordPress, members (users=authors) can change their profile and fill up some custom fields I added and I think it’s better if they don’t have to fill up two profile pages…

    Thanks

    <?php if ( $wp_profile_user = bb_get_user( get_post_author_id( $post_id ) ) ) : $wp_profile_link = esc_attr( "/members/{$wp_profile_user->user_nicename}/" )?><a href="<?php echo $wp_profile_link?>">View profile</a><?php endif?>

    Your profile pages from bbPress and WordPress should be in sync anyway if you’ve integrated properly…

    Oh Kawauso, thank you so much!! This code works perfectly!!

    But do you mean that normally, I should have just one profile page for WordPress and BBpress?

    Nope, but the same data should be available from either profile iirc

    Oups, actually, it is not the case :/ What do you think I’ve missed?


    serpicolugnut
    Member

    @serpicolugnut

    I’m having a similiar problem. I’m using bbpress integrated with our WordPress site. On the front-page.php page, in the “Latest Discussions” I’m using this bit of code:

    <?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><?php topic_page_links(); ?> by <a href="/wedding-chat/profile/<?php topic_author(); ?>" ><?php topic_author(); ?></a>

    Which gives me the users name, and a link to their profile page. The problem is that the link is using their username, which if the user has spaces or dashes, poses problems. I need to get the user_nicename or display_name value from that users record. How do I do this in bbPress? I’ve dug around, but I don’t see any information on the topic.

    Thanks!

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