Support » Plugin: amr users » Filter Shortcode for two values in same column

  • Resolved Tisha Oehmen


    I’m trying to write a shortcode filter that will only display results when they match one of two values. I can get the shortcode function to work properly with 1 value, as follows:

    [userlist list=5 filter=show join_date=2012-03]

    (join_date is the column I’m trying to filter by.)

    Is it possible to filter a column as for two values, ie 2012-04,2012-03? ie
    [userlist list=5 filter=show join_date=2012-04,2012-03]
    [userlist list=5 filter=show join_date="2012-04,2012-03"]

    Neither of these work, does it have to in an array format? (I’m actually using this in a template so can code full PHP if that’s what would be necessary.)

    Anyone able to do this successfully?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Nevermind all, I think I figured it out. It should be:

    [userlist list=5 fieldnamefilter=join_date, fieldvaluefilter=2012-04,2012-03]

    Problem resolved.

    Plugin Author anmari


    Hi Tisha,
    I’m happy that you think you resolved your problem.

    However it sounds like you only have one ‘field’ ie the join date in the column and I am wondering why you did not simply configure the list to ‘include’ only those dates?

    or if you insist on having a full list and only sometimes want to filter it (eg: front end)

    EG: if you only have one field

    The ‘fieldvaluefilter’ stuff is ONLY for people who for some weird reason are squishing multiple fields into one column and then STILL want to be able to filter by part of that column (very confusing…)

    Field filtering can place a load on your system as it will have to rerun reports realtime every page load…

    Fair question Anmari, my reason for not including it in the list itself was that I wanted to call the only most recent 3 months worth of new members (determined by the php call), and I didn’t want to update it every month. The widget I’ve constructed uses the following code:

    echo '<h4 class="widgettitle">Welcome Our Newest Members!</h4>';
    $thismonth = date('Y-m');
    $lastmonth = date('Y-m', strtotime("-1 month") ) ;
    $priormonth = date('Y-m', strtotime("-2 month") ) ;
    echo do_shortcode('[userlist list=5 fieldnamefilter=join_date, fieldvaluefilter='.$thismonth.','.$lastmonth.','.$priormonth.']');

    This seems to work OK, but if you have a better recommendation, I’d be very open to using it. Thanks for you efforts creating such a useful plugin!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Filter Shortcode for two values in same column’ is closed to new replies.