Info
- 6 posts
- 3 voices
- Started 1 year ago by Arturo
- Latest reply from Tom(dB)
- This topic is resolved
username function
-
- Posted 1 year ago #
hi, what's the function to have the username with bbpress? post_author() show the name and not the username.
for example, my username is arturo84, but with the post i see Arturo, so i want the function for the username.
thanks for the help. -
- Posted 1 year ago #
Have a look at bb-includes/functions.bb-template.php you'll see the functions
function get_post_author( $post_id = 0 )andfunction post_author_link( $post_id = 0 ).You'll need to recreate those in a plugin or in your functions file to use
$user->user_logininstead of$user->display_name.Have a look at profile.php in your theme to see how it is generated there. But remember that on post.php you'll have to pass in the ID of the post to get the username otherwise you'll be fetching details on the logged in user rather post author.
I hope that helps, good luck.
An easier way would be to take away the ability to allow change of display name. Then it will default to username anyway. Have a look at topic/help-with-basic-command-to-add-new-profile-fields if that's the avenue you want to take. If you do, don't forget to set everyones 'nicename' back to what their username is.
-
- Posted 1 year ago #
in profile.php i've found this <?php echo get_user_name( $user->ID ); ?> but in post.php don't print nothing... i don't know bbpress very good to recreate the function :(
any idea for a simplest way?
thanks!
-
- Posted 1 year ago #
<?php $user = bb_get_user( get_post_author_id() ); echo $user->user_login; ?> -
- Posted 1 year ago #
u''re the best! thanks Ben!
-
- Posted 1 year ago #
oh yeah. Doh! Cheers, Ben L.
-
You must log in to post.