This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Date Filter: Who is working today

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Date Filter: Who is working today

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #52288

    Purpose: I want have a filter, preferably a button that filters only the employee available today. I would like that boutton to be a slider defaulting on “Working Today” but let the user change that slider to “All” to show all employees. If possible I would like to have another calendar based field that would show the employees working on the day specified.

    What I did so far: I created a custom post type called Attendant to which I associated an advance custom field with a “Multi Dates Picker” type . Each record in the custom post type will be associated with that field and it will contain the dates that each attendant will work.

    I created a loop item using the custom post type. I bought Ajax Search Pro, I created a Search Instance, to which I associated the custom post type in the search sources. I also created in the Frontend Search Settings an option for custom field.

    Results: I associated the elementor post widget to the elementor setup and added the search custom code the page. A search field shows up, but as explained earlier that’s not the purpose of why I’m trying to accomplish. Is it possible to guide me towards my goal?

    #52301
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    This may require some custom coding in my opinion – all because of the multidate picker. That is a very complex field and I’m not sure if it’s possible to simply filter based on it’s value, as it’s not a single date, but likely an array of date fields.

    However, I believe it is very likely possible to create a radio button or even a checkbox type of filter to choose to show between All/Working Today values.

    Can you please add temporary FTP and back-end access? I will have to take a direct look at this, as I don’t know how the multidate picker stores the values. Based on the exact setup I will try to suggest a custom code snippet, which would convert the All/Working Today checkbox/radio filter to an actual results filter in the post processing based on the user selection.

    #52306

    Thank you. I added the temporary FTP and back-end access. A radio button is a good compromise, I was initially thinking of even hiding the filter option. Could that configuration be used without Elementor Pro? I was wondering if the combination Blocksy Pro/ Guttenberg could be an option as I am trying to get away from subscription since I will not be the owner of that website once all is done.

    #52313
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #52316

    Thank you for your quick response, I just updated the information, is it possible to let me know if it doesn’t work?

    #52329
    Ernest MarcinkoErnest Marcinko
    Keymaster

    The back-end login now works perfectly, thank you! However I can’t connect via FTP, can you please check that as well?

    I was able to check the date structure, I believe this should be possible via a custom code snippet. Let me know if you can check the ftp access, and I will test a possible solution.

    #52331

    Hi, thank you. I updated the username, I think that was the issue.

    #52367
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Pefrect!

    I have managed to put together a fairly tiny code snippet, which seems to be working. I have placed it into the code snippet plugin you are using under the name “Ajax Search Pro – Today filter”.

    I have also changed the filter to a radio button, with a yes/no option. When “Yes” is clicked, then only results matching todays date should be displayed.

    For future reference, here is the custom code, it turned out to be only a few lines:

    add_filter('asp_query_args', function($args){
    	foreach ( $args['post_meta_filter'] as $k => &$filter ) {
    		if ( $filter['key'] !== 'days_worked' ) {
    			continue;
    		}
    		if ( $filter['value'] === 'no' ) {
    			unset($args['post_meta_filter'][$k]);
    		}
    		$filter['value'] = date('Y-m-d');
    	}
    	
    	return $args;
    });
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.