Skip to:

Enforce field visibility except for admin

  • Jo Waltham



    I’m just dipping my toe into BuddyPress and my client needs to moderate profile changes but I haven’t been able to find any solution yet. To that end I’m having a go at developing something myself but I’m a bit stuck.

    My approach so far has been to create a new visibility level of ‘moderated’ and make it hidden unless you are admin.

    To stop people from changing the visibility level themselves I’ve set the the visibility to ‘Enforce field visibility’ but this stops admin from being able to change it on the user’s profile too.

    So is there a way I can introduce a third option of ‘Enforce field visibility except for admin’?

    Just for context, my next steps (not yet attempted) are to on save of profile to email admin and set all the users fields to moderated. Then on admin view of a profile to have a button that changes fields with moderated visibility back to their defaults. Does this sound like I’m on the right track?

    Thanks for your help!

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

  • Jo Waltham


    Oh I think I’ve got it 🙂

     add_filter( 'bp_current_user_can', 'jmw_permit_admin_to_edit_field_visibility', 10, 4 );
     function jmw_permit_admin_to_edit_field_visibility( $retval, $capability, $blog_id, $args ) {
     	if( 'bp_xprofile_change_field_visibility' == $capability && is_super_admin() ) {
     		$retval = true;
     	return $retval;

    Henry Wright


    Hi Jo

    Just wanted to point out if you have network mode enabled, is_super_admin() won’t catch normal administrators.

    Instead, you can use current_user_can( 'manage_options' ). That’ll catch admins if network mode isn’t enabled and both admins and super-admins if network mode is enabled.

    Jo Waltham


    Thank you Henry, I’ve changed that.

    I’ve put my full code on github
    but I’ll start another thread here asking for feedback on that.

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