Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Hide possibility to change 'Base' name


  • Amic58
    Participant

    @amic58

    Hello,
    I have a gaming community, where I would like people to have Names they added on registration page, but in the Profile -> Edit, you can change the name, and because of Internet trolls and others I would like to prevent this to happen.
    Is there any possibility to hide this “Edit ‘Base’ group profile Name” ?

    Thank you.

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

  • Tecca
    Participant

    @tecca

    Add to your CSS:

    #profile-edit-form .field_1 {
        display: none;
    }

    It’ll hide it, but it’s possible to still edit if the user knows how to use an inspection tool like Firebug or Chrome Inspector. You can also use a Javascript method, but a user can disable JS to get around that as well.

    I doubt anyone will try to get around it, though.


    Amic58
    Participant

    @amic58

    Thank you very much! I was looking for the fix for so long, but I never found one, didn’t know it was that easy.
    Also, if it is possible to hide another ‘Base’ name fields.
    In extended profile, there is a similar function like in Profile page.
    On WordPress Dashboard, when you click Profile, there is a possibility to view Extended profile like on the page before. There is also possibility to change the name.
    I also would like to hide the field Name (required), as I don’t want to push people to use their real names.
    I use the plugin called Usernames only that eliminates possibility to use real names, but the problem is that people won’t like to add their real name during registration.


    danbp
    Moderator

    @danbp

    Hi @amic58, @tecca

    When BP is installed and xProfile is activated, the original WP profile settings are not accessible to user.

    The WP register process use only username, password and email and BuddyPress add by default a Name field as base for other extended profile fields.

    In short this means that username and name fields can contain a same information(a name, a pseudonym, a first or/and a last name). The plugin you mention is best for a WP install where user had choosen first/last name as output on post, comments, etc Once BP is activated, this became a little different.

    Now to the initial question.
    The CSS trick is a very inelegant solution as it lets everybody knowing how BP works to surround this invisibility. You’re also loosing any flexibility if you want to show some fields privately for example.

    You can do this properly with a little snippet, as explained here:

    Using bp_parse_args() to filter BuddyPress template loops

    Here’s an example which let you hide fields or fiels group to members, but not to site admin

    function bpfr_hide_profile_field_group( $retval ) {
    	if ( bp_is_active( 'xprofile' ) ) :	
    	
    	// hide profile group/field to all except admin	
    	if ( !is_super_admin() ) {		
    		//exlude fields, separated by comma
    		$retval['exclude_fields'] = '1';  
    		//exlude groups, separated by comma
    		$retval['exclude_groups'] = '1'; 			
    	} 
    	return $retval;		
    	
    	endif;
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );

    Add it to bp-custom.php or your child-theme functions.php

    Of course you can also choose to show a field or group, but remove the possibility for the user to edit it later. Simply add more conditionnal to the function.

    Here another example:

    function bpfr_hide_profile_edit( $retval ) {	
    	// remove field from edit tab
    	if(  bp_is_user_profile_edit() ) {		
    		$retval['exclude_fields'] = '54'; // ID's separated by comma
    	}	
    	// allow field on register page
    	if ( bp_is_register_page() ) {
    		$retval['include_fields'] = '54'; // ID's separated by comma
    		}		
    	
    	// hide the field on profile view tab
    	if ( $data = bp_get_profile_field_data( 'field=54' ) ) : 
    		$retval['exclude_fields'] = '54'; // ID's separated by comma	
    	endif;	
    	
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_edit' );

    Hope to be clear.


    Amic58
    Participant

    @amic58

    Thank you very much! I used the first snippet and it did the trick with hiding things.
    I can’t believe I was searching for the solution myself for a long time even though the solution is pretty much simple. Looks like I have to learn HTML 🙂

    Thank you again, I am so happy that my problems are solved now.


    danbp
    Moderator

    @danbp

    Sorry to answer you with a big laught, it’s not html but php. 😀
    You should also find the time to read more attentively the forum, or search by keywords.
    in this case: hide xprofile fields

    https://buddypress.org/support/search/hide+xprofile+fields/

    You’re welcome. Glad you got it. 😉


    Amic58
    Participant

    @amic58

    Well, that was embarrassing.. 😀 Sorry for my stupidity.
    I was searching on forums by “Disable name change” “Hide Name in registration” etc. Most answers I found were outdated, that’s why I registered to ask.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Hide possibility to change 'Base' name’ is closed to new replies.
Skip to toolbar