Username Privacy

This topic contains 16 replies, has 3 voices, and was last updated by  Giri 6 years, 6 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #562

    Joy
    Buyer
    Post count: 1076

    Hello, is there a way that we can mask the users First and Last names? Maybe just display with an initial?

    If possible, I would like to have the reviews to be posted with their first name and last name initial, but their profile with their username. The way it is now. So their first name with their last name initial would be on the profile page, but their link would be their /profile/username

    I’m not sure if that’s confusing. I think that reviews would look more credible with first names and last initial instead of a username that a member might choose. But at the same time, members may not want their full name being posted.

    Thank you.

    #563

    Guust
    Moderator
    Post count: 29970

    First and last names can be set to “yes/no/let user decide”.
    There is a field called Display Name you can make required.

    That probably solves your issue?

    Thanks

    #568

    Joy
    Buyer
    Post count: 1076

    No, I would prefer to have the first and last names used, but for privacy reasons, the users last names should be masked.

    I also do utilize the display name field, that’s the name that appears in their profile link.

    #572

    Guust
    Moderator
    Post count: 29970

    There is no option to only show the first letter of the last name.
    You cannot show it, or allow users to decide if it will be shown.

    Thanks

    #573

    Joy
    Buyer
    Post count: 1076

    Thank you Guust. Yes, I understand that it’s not available. But perhaps it could be implemented in the next update. I think that this is a reasonable request so maybe @giri may consider it. 😉

    #582

    Joy
    Buyer
    Post count: 1076

    Just wanted to update in case anyone else was interested in this feature. I added a code snippet to achieve this. So instead of John Doe members names on the front-end will appear at John D.:

    
    
    add_action( 'admin_init', 'fix_display_name' );
    function fix_display_name() {
    	$users = get_users();
    	foreach( $users as $user ){
    		if( $user->first_name != '' && $user->last_name != '' ){
    			$display_name = $user->first_name . ' ' . substr( $user->last_name, 0, 1 ) . '.';
    			wp_update_user(
    				array(
    				      'ID' => $user->ID,
    				      'display_name' => $display_name
    				      )
    			);
    		}
    	}
    }
    
    add_action( 'admin_head', 'hide_profile_field' );
    function hide_profile_field() {
        ?>
        <script type="text/javascript">
        jQuery(function($) {
            $('.user-nickname-wrap, .user-display-name-wrap').hide();
        });
        </script>
        <?php
    }
    #584

    Guust
    Moderator
    Post count: 29970

    Thanks for sharing.

    #628

    Giri
    Expired Member
    Post count: 3155

    Hi Joy,

    I’m glad you made it work.

    Make sure to disable display name field. So your user can’t able to update them.

    Also you may need a function to update the display name if your user update the firstname and last name.

    Hope that helps.

    Thanks

    #640

    Joy
    Buyer
    Post count: 1076

    Hi Giri,

    Is there a way to get the user names and display names to be set as read only? Also, is there any negative effects if users decide to change their first/last names or their display names? Thank you.

    #644

    Giri
    Expired Member
    Post count: 3155

    Hi Joy, Set the fields to admin use only and then add this snippet.

    https://userswp.io/support/topic/disabling-text-box/page/2/#post-486

    Thanks

    #656

    Joy
    Buyer
    Post count: 1076

    Thanks Giri. However, I don’t see any admin use on the first name, last name, or username fields. I only see the option appear if I add a new text box. Am I doing something wrong? I tried to download and reinstall the latest version from Github too.

    #694

    Joy
    Buyer
    Post count: 1076

    HI @giri, not sure if you missed my last response since the topic is marked as resolved. Just bumping this again.

    Thank you.

    #696

    Giri
    Expired Member
    Post count: 3155

    Hi Joy,

    Apologies. I guess I disabled that admin use option for the default fields.

    Disabling default fields is not a good idea.

    You seem like you are doing it wrong. Are you planning to disable those fields only to display the name differently?

    #707

    Joy
    Buyer
    Post count: 1076

    I would just like the account first name, last name, and username to appear on the account settings form, but I want them to be read-only fields.

    #709

    Giri
    Expired Member
    Post count: 3155

    Hi Joy,

    I have added a filter.

    You would need to download the latest. I think stiofan is gonna release in wp.org.

    So you can get it from there.

    Once you have the latest version, add this snippet.

    
    
    add_filter('uwp_form_input_field_text', 'custom_uwp_form_input_field_text', 10, 3);
    function custom_uwp_form_input_field_text($field, $value, $form_type) {
        if ($form_type == 'account') {
            if (
                $field->htmlvar_name == 'uwp_account_first_name'
                || $field->htmlvar_name == 'uwp_account_last_name'
                || $field->htmlvar_name == 'uwp_account_username'
            ) {
                $field->for_admin_use = '1';
            }
        }
        return $field;
    }

    Thanks

Viewing 15 posts - 1 through 15 (of 17 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket