This may get all the active photographers and editors and then all the inactive photographers and editors as 2 shortcodes:
function sul_custom_meta_query( $args, $query_id ){
switch ( $query_id ) {
case 'active_meta_query':
$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'function',
'compare' => 'IN',
'value' => array( 'photographer', 'editor' ),
),
array(
'key' => 'status',
'compare' => '=',
'value' => 'active'
),
);
break;
case 'inactive_meta_query':
$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'function',
'compare' => 'IN',
'value' => array( 'photographer', 'editor' ),
),
array(
'key' => 'status',
'compare' => '!=',
'value' => 'active'
),
);
break;
}
return $args;
}
add_filter( 'sul_user_query_args', 'sul_custom_meta_query', 10, 2 );
You’d need to specify the query id in your shortcode like so:
[userlist query_id="active_meta_query"]
and then for the non-active folks:
[userlist query_id="inactive_meta_query"]
It might be possible to display all the photographers and editors and then group/sort them. This is totally untested though so I don’t know if it will work, but here’s an attempt to sort the users by the active
meta key. This would be the shortcode [userlist query_id="my_custom_meta_query"]
. Since this function is named the same as the one above don’t use them both at the same time or you will get a fatal error.
function sul_custom_meta_query( $args, $query_id ){
if( $query_id == 'my_custom_meta_query' ){
$args['meta_key'] = 'status';
$args['orderby'] = array( 'meta_value', 'display_name' );
$args['meta_query'] = array(
array(
'key' => 'function',
'compare' => 'IN',
'value' => array( 'photographer', 'editor' ),
)
);
}
return $args;
}
add_filter( 'sul_user_query_args', 'custom_meta_query', 10, 2 );
Good luck! Let me know if any of this works or if you find a good solution.