WordPress.org

Ready to get started?Download WordPress

Forums

amr users
[resolved] Filter Shortcode for two values in same column (5 posts)

  1. Tisha Oehmen
    Member
    Posted 1 year ago #

    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]
    or
    [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?

    http://wordpress.org/extend/plugins/amr-users/

  2. Tisha Oehmen
    Member
    Posted 1 year ago #

    Nevermind all, I think I figured it out. It should be:

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

  3. Tisha Oehmen
    Member
    Posted 1 year ago #

    Problem resolved.

  4. anmari
    Member
    Plugin Author

    Posted 1 year ago #

    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)
    http://wpusersplugin.com/2876/simple-column-filtering-in-amr-users-lists/

    EG: if you only have one field
    http://directories.wpusersplugin.com/memberdetails/?filter=1&REGION=Africa

    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...

  5. Tisha Oehmen
    Member
    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic