User search conditional brackets and exclude by usermeta values

Home Forums Product Support Forums Ajax Search Pro for WordPress Support User search conditional brackets and exclude by usermeta values

This topic contains 2 replies, has 2 voices, and was last updated by davsev davsev 5 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #16423
    davsev
    davsev
    Participant

    Hey,
    I try to use conditional

    Conditional bracket examples
    

    in user search.

    I enter the brackets in the Advanced description field but it doesn’t work.

    this is the code:

    
    [<strong>שם החברה:</strong>{pie_text_7} &lt;br /&gt;]
    [<strong>מספר רשיון תיווך:</strong>{pie_phone_10} &lt;br /&gt;]
    [<strong>נייד:</strong>{pie_phone_10} &lt;br /&gt;]
    [<strong>טלפון במשרד:</strong> {pie_phone_11}] 
    

    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:

    $args = array(
        'role' =&gt; 'Author',
        'meta_query' =&gt; array(
            'relation' =&gt; 'AND', 
            array(
                'key' =&gt; 'active',
                'value' =&gt; '1',
                'compare' =&gt; '=',
            ),
            array(
                'relation' =&gt; 'OR', 
                    array(
                        'key' =&gt; 'wp_w3dev_user_banned',
                        'value' =&gt; '1',
                        'compare' =&gt; '!=',
                    ),
                    array(
                        'key' =&gt; 'wp_w3dev_user_banned',
                        'compare' =&gt; 'NOT EXISTS',
                    ),
            ),    
        ),
    );

    Thank you.
    David

    #16443
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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:

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #16447
    davsev
    davsev
    Participant

    Works like magic!!!
    Now just one more thing,
    Is it possible to assign this filters to a specific form?

    • This reply was modified 5 years, 2 months ago by davsev davsev.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.