Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide xProfile fields from EDIT


  • Jek-fdrv
    Participant

    @jek-fdrv

    wp v4.6.1
    bp v2.7.0
    Theme: Twenty Sixteen
    Cant provide link, it is on my local.
    I am web developer.

    Hello, I would like to ask you about xprofile fields for users.
    I have add 2 profile fields groups, with fields.
    Right now I am wondering if it is possible to hide them from:
    Single profile page. From show tab and from EDIT tab.
    From dashboard profile edit page.
    From custom profile fields.
    From tabs every where.

    I have tried to use this code:
    function bpfr_hide_profile_field_group( $retval ) {
    $retval[‘exclude_groups’] = ‘0,1,2’;
    return $retval;
    }
    It hide fields only from show on single profile page but not from edit.
    Thank you very much.
    Very appreciate your help.

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

  • danbp
    Participant

    @danbp

    – 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' );

    Jek-fdrv
    Participant

    @jek-fdrv

    Thank you very much!
    But here what I got.

    Fatal error: Uncaught Error: Call to undefined function bp_is_user_edit() in wp-content/plugins/player-info-collector/player-info-collector.php on line 293

    I have fund this code

    function bp_is_profile_edit() {
    _deprecated_function( __FUNCTION__, ‘1.5’, ‘bp_is_user_profile_edit()’ );
    return bp_is_user_profile_edit();
    }

    But bp_is_user_profile_edit seems doesnt work at all.


    Jek-fdrv
    Participant

    @jek-fdrv

    Hello? =)


    danbp
    Participant

    @danbp

    Sorry for the outdated trick.
    bp_is_profile_edit is deprecated in favor of bp_is_user_profile_edit.

    Check for the outdated fn in the plugin mentionned in the error msg.
    In case of, here a tutorial with more options.


    Jek-fdrv
    Participant

    @jek-fdrv

    But how to hide the tab, right now it works. But it show the tab – group of fields which I want to hide. SO when user click on the tab, there is no fields to show. If there any way how I can exclude tabs? Or just simple css to hide?


    Jek-fdrv
    Participant

    @jek-fdrv

    This code with $data… What is the data should be? =)

    if ( $data = bp_get_profile_field_data( ‘field=54’ ) )


    danbp
    Participant

    @danbp

    It relate to this filter bp_get_profile_field_data

    This example will hide tabs and fields to all except 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'] = '3'; 			
    	} 
    	return $retval;		
    	
    	endif;
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );

    These tricks hide the tab content, not the tab itself. (it seems that it doesn’t work for groups at the moment…i asked devs for information) Use CSS display:none to hide the tab or consider this plugin.


    Jek-fdrv
    Participant

    @jek-fdrv

    Okay! Thank you very much!
    I am really glad to get help here from you.
    Thank you again.


    danbp
    Participant

    @danbp

    @jek-fdrv,

    we’ve discussing about this “tab” issue on this ticket:
    https://buddypress.trac.wordpress.org/ticket/7304

    I invite you to jump in if you have any comments. You might also find a solution for your use case.


    Jek-fdrv
    Participant

    @jek-fdrv

    Oh, perfect!
    I will track this ticket!

    Thank you very much again! =)

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