WordPress.org

Ready to get started?Download WordPress

Forums

Simple User Listing
[resolved] Search and listing between age group (2 posts)

  1. bffnb
    Member
    Posted 7 months ago #

    Hi!

    I need a search shortcode for BETWEEN age groups for example 30 -40 year old users. Every listing for the exact age group or under 30 for example works great.

    [userlist meta_key="age" meta_value="30" meta_compare="<"]
    [userlist meta_key="age" meta_value="30"]

    But i need a listing for BETWEEN two age groups? I found on
    http://codex.wordpress.org/Class_Reference/WP_User_Query
    the code:

    Multiple custom user fields handling

    $args = array(
    'meta_query' => array(
    'relation' => 'OR',
    array(
    'key' => 'country',
    'value' => 'Israel',
    'compare' => '='
    ),
    array(
    'key' => 'age',
    'value' => array( 20, 30 ),
    'type' => 'numeric',
    'compare' => 'BETWEEN'
    )
    )
    );
    $user_query = new WP_User_Query( $args );

    BUT I HAVE NOT THE SCILLS TO MAKE IT HAPPEN :)

    Can you help me out to create a shortcode to list users between two age groups? Will be great...

    Thank you so much

    http://wordpress.org/plugins/simple-user-listing/

  2. helgatheviking
    Member
    Plugin Author

    Posted 7 months ago #

    I don't believe that "between" is a type of meta compare that is supported by WordPress, therefore it is not supported by my plugin.

    You can filter the user query arguments via the pre_user_query filter (or the simple_user_listing_args ... see the plugin FAQ for an example) and attempt to implement a complex meta query, like suggested here: http://stackoverflow.com/questions/12199322/compare-two-meta-values-in-wordpress

    However, this type of customization goes well beyond the scope of free support for this plugin, so I can't help you implement it.

    Cheers.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.