diff --git src/bp-xprofile/bp-xprofile-caps.php src/bp-xprofile/bp-xprofile-caps.php
index 01ef503..f34925f 100644
|
|
defined( 'ABSPATH' ) || exit; |
25 | 25 | function bp_xprofile_map_meta_caps( $caps, $cap, $user_id, $args ) { |
26 | 26 | switch ( $cap ) { |
27 | 27 | case 'bp_xprofile_change_field_visibility' : |
28 | | $caps = array( 'exist' ); // Must allow for logged-out users during registration. |
| 28 | $caps = array( 'exist' ); |
29 | 29 | |
30 | 30 | // You may pass args manually: $field_id, $profile_user_id. |
31 | 31 | $field_id = 0; |
… |
… |
function bp_xprofile_map_meta_caps( $caps, $cap, $user_id, $args ) { |
71 | 71 | return apply_filters( 'bp_xprofile_map_meta_caps', $caps, $cap, $user_id, $args ); |
72 | 72 | } |
73 | 73 | add_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 | */ |
| 85 | function 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 | } |
| 92 | add_filter( 'bp_user_can', 'bp_xprofile_grant_bp_xprofile_change_field_visibility_for_logged_out_users', 10, 3 ); |