Skip to:
Content

BuddyPress.org

Ticket #7298: 7298.diff

File 7298.diff, 1.4 KB (added by boonebgorges, 9 years ago)
  • src/bp-xprofile/bp-xprofile-caps.php

    diff --git src/bp-xprofile/bp-xprofile-caps.php src/bp-xprofile/bp-xprofile-caps.php
    index 01ef503..f34925f 100644
    defined( 'ABSPATH' ) || exit; 
    2525function bp_xprofile_map_meta_caps( $caps, $cap, $user_id, $args ) {
    2626        switch ( $cap ) {
    2727                case 'bp_xprofile_change_field_visibility' :
    28                         $caps = array( 'exist' ); // Must allow for logged-out users during registration.
     28                        $caps = array( 'exist' );
    2929
    3030                        // You may pass args manually: $field_id, $profile_user_id.
    3131                        $field_id        = 0;
    function bp_xprofile_map_meta_caps( $caps, $cap, $user_id, $args ) { 
    7171        return apply_filters( 'bp_xprofile_map_meta_caps', $caps, $cap, $user_id, $args );
    7272}
    7373add_filter( 'bp_map_meta_caps', 'bp_xprofile_map_meta_caps', 10, 4 );
     74
     75/**
     76 * Grant the 'bp_xprofile_change_field_visibility' cap to logged-out users.
     77 *
     78 * @since 2.7.1
     79 *
     80 * @param bool   $user_can
     81 * @param int    $user_id
     82 * @param string $capability
     83 * @return bool
     84 */
     85function bp_xprofile_grant_bp_xprofile_change_field_visibility_for_logged_out_users( $user_can, $user_id, $capability ) {
     86        if ( 'bp_xprofile_change_field_visibility' === $capability && 0 === $user_id ) {
     87                $user_can = true;
     88        }
     89
     90        return $user_can;
     91}
     92add_filter( 'bp_user_can', 'bp_xprofile_grant_bp_xprofile_change_field_visibility_for_logged_out_users', 10, 3 );