mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Display assigned roles in search filter 'role' field
This commit is contained in:
+12
-7
@@ -139,34 +139,39 @@ class UM_Members {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display assigned roles in search filter 'role' field
|
||||
* @param array $attrs
|
||||
* @return array
|
||||
* @uses add_filter 'um_search_select_fields'
|
||||
* @since 1.3.83
|
||||
*/
|
||||
function um_search_select_fields( $attrs ) {
|
||||
global $ultimatemember;
|
||||
|
||||
if( strstr( $attrs['metakey'], 'role_') ){
|
||||
if( strstr( $attrs['metakey'], 'role_' ) ){
|
||||
|
||||
$shortcode_roles = get_post_meta( $ultimatemember->shortcodes->form_id, '_um_roles', true );
|
||||
$um_roles = $ultimatemember->query->get_roles( false );
|
||||
|
||||
if( ! empty( $shortcode_roles ) ){ // if no roles are selected or page is accessible by everyone
|
||||
if( ! empty( $shortcode_roles ) && is_array( $shortcode_roles ) ){
|
||||
|
||||
$attrs['options'] = array();
|
||||
|
||||
if( ! is_array( $shortcode_roles ) ) {
|
||||
$shortcode_roles = array();
|
||||
}
|
||||
|
||||
foreach ( $um_roles as $key => $value ) {
|
||||
if ( in_array( $key, $shortcode_roles ) ) {
|
||||
$attrs['options'][ $key ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***
|
||||
|
||||
Reference in New Issue
Block a user