• Resolved user4forum

    (@user4forum)


    Hi,
    thank you for this great plugin – a functionality that should actually be found in the core of BuddyPress.

    I have the following filter function in a directory search.

    [bps_directory bp_member_type_one_of='My-MT-Group' AND field_76_range='2024-01-01, 2024-12-31']

    I would like to specify a daily filter for the first date field so that “older” profiles are not displayed. Unfortunately, I can only find information for fixed periods in the documentation.

    [bps_directory field_76_range='%TODAY%, 2024-12-31']

    If such a variable is not implemented, what would a pre-database search look like as a snippet for this plugin in order to then be able to make additional selections using a BPS form?

    A simple preliminary search would be like this:

    SELECT * FROM wp_bp_xprofile_data
    WHERE field_id = 76
    AND value >= CURDATE() AND '2024-12-31';

    In this case, the filter function with the member type would be sufficient!

    I would like to thank you in advance for an answer.

    • BP Profile Search 5.7
      WP 6.4.2,
      BP 12.2.0 & BP Classic 1.3.0,
      PHP 7.4.x, MariaDB 10.x
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hi user4forum,

    You could use the ‘bps_hidden_filters’ hook. Add this code to your bp-custom.php file:

    add_filter ('bps_hidden_filters', 'my_hidden_filters');
    function my_hidden_filters ($filters)
    {
    	if (isset ($filters['field_76_range']))
    		$filters['field_76_range']['min'] = date ('Y-m-d');
    	return $filters;
    }
    
    Thread Starter user4forum

    (@user4forum)

    Hi Andrea,

    unfortunately your suggested snippet doesn’t work. If ‘date’ should output the current date, user profiles with older date entries will still be displayed.

    In the meantime I have found a less elegant solution and have the BPS page updated regularly (cronjob) at midnight with a variable placeholder.

    TODAY='date +%Y-%m-%d'

    This is also how the original shortcode works.

    [... AND field_76_range='$TODAY, 2024-12-31']

    Thank you very much for your support.

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi user4forum,

    Glad to hear you found a suitable solution, and thanks for sharing it here!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Two filters and variable for timestamp’ is closed to new replies.