Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Desperate! I need to make base field not public


  • csimpson
    Participant

    @csimpson

    hello all, i’m in desperate need of just making the Full Name field not a public field.

    i want it to be seen by the member on their own profile and an admin, but not public when members are viewing each other’s profiles.

    just like all other extended fields where you can choose visibility

    bit surprised i cant find an answer to this anywhere!!

    please help!

    many thanks in advance, Craig

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

  • danbp
    Participant

    @danbp

    Hi @csimpson,

    the answer is on the codex (bp_parse_args)

    Add this to your theme’s functions.php or into bp-custom.php

    function bpfr_make_name_members_only( $retval ) {	
    	//hold all of our info
    	global $bp;
    	
    	// is xprofile active ?	
    	if ( bp_is_active( 'xprofile' ) )
    	
        // The user ID of the currently logged in user
        $current_user_id = (int) trim($bp->loggedin_user->id);
    	
        // The author that we are currently viewing
        $author_id  = (int) trim($bp->displayed_user->id);
    	 
    	// user can see only his name && admin can see everyone 
    	if ($current_user_id !== $author_id && !current_user_can('delete_others_pages') ) {
    		$retval['exclude_fields'] = '1';	
    	}
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_make_name_members_only' );

    EDIT: this snippet does work only on BP 2.0+. Don’t use it with older versions.


    csimpson
    Participant

    @csimpson

    wow, and thank you so much danbp! it worked a treat. i am very grateful for this. best wishes craig


    danbp
    Participant

    @danbp

    You’re welcome !
    I mark this as resolved and close the topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Desperate! I need to make base field not public’ is closed to new replies.
Skip to toolbar