Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Profile > Field > Default Visibility / Getting a field's visability

  • @chiefalchemist

    Participant

    Greetings!

    In short the need is to have some profile fields that are “Management Only” and also “Seen by others but added/ edited by Management Only.” For example, a list of skills. We want Management to vet the staff member and check off their skills, but only allow those skills to be displayed within a profile (and can’t actually be edited by that person). I hope my explanation is making sense.

    We’d also like to be able to query by some of those (if that detail is helpful).

    1) So I’m looking for a way to add to the Default Visibility list. Is that possible?

    2) Or can I add a custom taxonomy (?) to the fields and then work my own magic that way?

    3) Else, what about being able to get a field’s Visibility setting and override that? For example in profile-loop.php as I’m looping (in pseudo-code): “If wp_role == “management” and visibility == “me only”) then allow edit). and if role != management then only display the values – no edit.

    I think we can live without “Management Only” but we do need “fields management fills out and everyone gets to see”.

    Finally, this is my first BP project. My WP powers are pretty good but my BP close to zero. Please type slowly 🙂

    Thanks
    mfs

    p.s. Also, is there was way to create profile fields with code instead of via the Admin UI?

Viewing 2 replies - 1 through 2 (of 2 total)
  • @shanebp

    Moderator

    I wouldn’t rely on messing with visibility settings.
    To make a profile field only editable by admins, do this in bp-custom.php or a plugin:

    // only admins can edit the Skills field
    function chief_hide_profile_fields( $retval ) {
    	
    	if( is_super_admin () )
    		return $retval;
    
    	if(  bp_is_profile_edit() || bp_is_register_page() )
    		$retval['exclude_fields'] = '3';	//profile field ID's separated by comma
    
    	return $retval;
    
    }
    add_filter( 'bp_after_has_profile_parse_args', 'chief_hide_profile_fields' );

    Note that you need to add the correct id(s) for exclude_fields.
    And that ‘ || bp_is_register_page() ‘ keeps the field(s) off the register page – which you may not need to do.

    Re how to create profile fields in code, there a couple of ways to do it depending on the kind of field and how it will be used.
    Take a look at these plugins for more info:
    https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/
    https://wordpress.org/plugins/buddypress-xprofile-image-field/

    @chiefalchemist

    Participant

    => re: “Note that you need to add the correct id(s) for exclude_fields.”

    Thanks shanebp. But is this the only way? I mean, I can’t do mucking with the code every time the client wants something new? Can I?

    => re: …/buddypress-xprofile-custom-fields-type/

    “Add new visibility setting “Nobody”. Hide the field to all members.”

    So this means, I presume that custom visibility is possible. Yes?

    That said, I want to use standard fields, but I want to create the list via code, and not have to do it manually. Not possible? Mind you, it could be cause I’m new to BP but I’m trying to where / how the profile definitions are stored. I presume it’s an array, or close. So I want to do that but with code.

    Thanks again

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Profile > Field > Default Visibility / Getting a field's visability’ is closed to new replies.
Skip to toolbar