Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bpfr_hide_profile_edit'

Viewing 5 results - 1 through 5 (of 5 total)
  • Author
    Search Results
  • #260210
    danbp
    Participant

    – Single profile page. From show tab and from EDIT tab (see snippet)

    – From dashboard profile edit page: not possible – normally BP users shouldn’t have access to profile dashboard. They can manage their profile from front-end.

    – From custom profile fields. (see snippet)
    – From tabs every where. (see snippet)

    Almost any described areas, as example

    function bpfr_hide_profile_edit( $retval ) {	
    	// remove field from edit tab
    	if(  bp_is_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' );
    #243428
    danbp
    Participant

    @katiemeeks

    You could also use one of these snippet in bp-custom

    #230718
    danbp
    Participant

    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.

    #230638
    danbp
    Participant

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

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

    Hi @ww2boy,

    Yes ! 😉 Give this a try. Add it to child theme’s functions.php or bp-custom.php

    function bpfr_hide_profile_edit( $retval ) {	
    	// remove field from edit tab
    	if(  bp_is_profile_edit() ) {		
    		$retval['exclude_fields'] = '54'; // ID's separated by comma
    	}	
    	// allow field on registration page     
    	if ( bp_is_register_page() ) {
    		$retval['include_fields'] = '54'; // ID's separated by comma
    		}		
    	
    	// hide the filed 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' );

    Codex reference:
    https://codex.buddypress.org/plugindev/using-bp_parse_args-to-filter-buddypress-template-loops/

Viewing 5 results - 1 through 5 (of 5 total)
Skip to toolbar