Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › User search conditional brackets and exclude by usermeta values
- This topic has 2 replies, 2 voices, and was last updated 8 years, 4 months ago by
davsev.
-
AuthorPosts
-
January 21, 2018 at 8:06 am #16423
davsev
ParticipantHey,
I try to use conditional [code]Conditional bracket examples
[/code] in user search.I enter the brackets in the
Advanced description fieldbut it doesn’t work.this is the code:
[code]
[<strong>שם החברה:</strong>{pie_text_7} <br />]
[<strong>מספר רשיון תיווך:</strong>{pie_phone_10} <br />]
[<strong>נייד:</strong>{pie_phone_10} <br />]
[<strong>טלפון במשרד:</strong> {pie_phone_11}]
[/code]Without the brackets it works great but I want to avoid empty lines.
Another issue,
How can I exclude from search result users that don’t have certain value in user meta field:
Something like this meta_query:[code]$args = array(
‘role’ => ‘Author’,
‘meta_query’ => array(
‘relation’ => ‘AND’,
array(
‘key’ => ‘active’,
‘value’ => ‘1’,
‘compare’ => ‘=’,
),
array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘wp_w3dev_user_banned’,
‘value’ => ‘1’,
‘compare’ => ‘!=’,
),
array(
‘key’ => ‘wp_w3dev_user_banned’,
‘compare’ => ‘NOT EXISTS’,
),
),
),
);[/code]Thank you.
DavidJanuary 22, 2018 at 5:08 pm #16443Ernest Marcinko
KeymasterHi,
1. The conditional brackets does not yet work with the user search fields, only with custom post types. The only solution is to use a custom code.
Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!2. This is unfortunately not possible via arguments, only with custom code to filter the users after the search process is finished. This is a bit more difficult, but this should help to get you started:
January 23, 2018 at 8:04 am #16447 -
AuthorPosts
- You must be logged in to reply to this topic.