User INFO is empty for custom role
-
In a previous post that is now closed, a forum member had created a new user role, but this user could not see Info on members. Below is the reported resolution to this problem, but when I tried to add it, this line of code is throwing an error.
add_filter( ‘user_has_cap’, function( $allcaps, $caps, $args, $WP_User ) {
if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX && in_array( ‘manage_options’, $caps ) ) {Any ideas on how to fix this error in the code? (see below for entire code)
Hi (@champsupertramp),
The issue was solved with the help of Ultimate Member support.
Just add add the code to the file functions.php in the active theme directory./**
* Add capability ‘manage_options’ dynamically when user retrieves information for the popup “Review Registration Details”
* @author Ultimate Member support <[email protected]>
* @since 2021-11-21
* @see #56270
*/
add_filter( ‘user_has_cap’, function( $allcaps, $caps, $args, $WP_User ) {
if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX && in_array( ‘manage_options’, $caps ) ) {$nonce = isset( $_REQUEST[‘nonce’] ) ? sanitize_text_field( $_REQUEST[‘nonce’] ) : ”;
$action = isset( $_REQUEST[‘action’] ) ? sanitize_key( $_REQUEST[‘action’] ) : ”;
$act_id = isset( $_REQUEST[‘act_id’] ) ? sanitize_key( $_REQUEST[‘act_id’] ) : ”;
$profile_id = isset( $_REQUEST[‘arg1’] ) ? absint( $_REQUEST[‘arg1’] ) : 0;if ( wp_verify_nonce( $nonce, ‘um-admin-nonce’ ) && ‘um_dynamic_modal_content’ === $action && ‘um_admin_review_registration’ === $act_id && um_can_view_profile( $profile_id ) ) {
$allcaps[‘manage_options’] = 1;
}
}
return $allcaps;
}, 20, 4 );
- The topic ‘User INFO is empty for custom role’ is closed to new replies.