Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change Default Display Name


  • daviddossantos
    Participant

    @daviddossantos

    Hello

    I am aware I can change the display name for each user manually by navigating to dashboard>users>all users>edit user and change “Display name publicly as” but I was hoping there was a way I could change the default “Display name publicly as” to first name only so all existing forum topics/ users change to first name only and future users also only show first name only. Is this possible?

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

  • Robin W
    Moderator

    @robin-w

    untested, but this should work

    add_filter( 'bbp_get_reply_author_display_name' , 'rew_reply_change_to_first_name', 10 , 2 ) ;
    
    function rew_reply_change_to_first_name ($author_name, $reply_id) {
    	// Get the author ID
    	$author_id = bbp_get_reply_author_id( $reply_id );
    	$user = get_userdata($author_id); 
    	$first_name = $user->user_firstname;
    return $first_name ;
    }
    
    add_filter( 'bbp_get_topic_author_display_name' , 'rew_topic_change_to_first_name', 10 , 2 ) ;
    
    function rew_topic_change_to_first_name ($author_name, $topic_id) {
    	// Get the author ID
    	$author_id = bbp_get_topic_author_id( $topic_id );
    	$user = get_userdata($author_id); 
    	$first_name = $user->user_firstname;
    return $first_name ;
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets


    thesupplyroom
    Participant

    @thesupplyroom

    Hi Robin!

    Thank you so much, that worked as expected! One question/ issue though – the objective is to completely anonymise the user, however, when you hover over the “first name” the user link still shows their first and last name

    example http://www.mywebsite.com/user/daviddossantos

    I guess this would be a difficult one to solve as the link uses their “username” so if thats set to firstnamelastname then we cant change it… right?

    Thank you for your help on this.

    David


    Robin W
    Moderator

    @robin-w

    pretty much – if you want to not show user profiles, then use

    bbp style pack

    once activated go to

    dashboard>settings>bbp style pack>Profile

    where you can set profiles not to display


    Kampbros
    Participant

    @kampbros

    Thank you guys.

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