• Hi,
    Please help with my ajax issue.
    Based on this post :
    https://wordpress.org/support/topic/fullcalendar-and-owner

    i’m able to filter my calendar view to display only events from a group, here is my snippet:

    function wpfc_filter_events( $args ) {
        /* Now pass the args to override default current values. */
        $group_id = '94'; // for test
        if (isset($group_id)) :
        $args['group'] = $group_id;
        endif;
        return $args;
    }
    add_filter( 'wpfc_fullcalendar_args', 'wpfc_filter_events', 10, 1);

    but what i (want) can’t manage to do is to call this filter in ajax!
    i want to switch between different calendar views when i click on different links in tabs, example: calendar 1, calendar 2, etc…

    here is what i have tried out in wp ajax without success:

    function wpfc_update_events_ajax( $args ) {
        /* Now pass the args to override default current values. */
        $group_id = $_POST['groupid'];
        if (isset($group_id)) :
        $args['group'] = $group_id; //ex: '94'
        endif;
    
        return $args;
    }
    //add_filter( 'wpfc_fullcalendar_args', 'wpfc_update_events_ajax', 10, 1);
    
    function my_planning_update_ajax() {
        add_filter( 'wpfc_fullcalendar_args', 'wpfc_update_events_ajax', 10, 1);
    }
    add_action( 'wp_ajax_my_planning_update_ajax', 'my_planning_update_ajax' );
    add_action( 'wp_ajax_nopriv_my_planning_update_ajax', 'my_planning_update_ajax' );

    this ajax function are call with the query ajax method when i clic on a link :

    $("div.menu>div.list-group>a").click(function(e) {
    
    e.preventDefault();
              $(this).siblings('a.active').removeClass("active");
              $(this).addClass("active");
              var index = $(this).index();
    
              var calendar = $('.wpfc-calendar');
              var group = $(this).attr('id');
    
                   var data = {
                      action: 'my_planning_update_ajax',
                      groupid: group
                  };
    
    $.post(ajaxurl, data, function(response) {
    
                    alert('Update Planning : ' + response);
    
                   // WPFC.data[group] = group;
                    //calendar.fullCalendar('removeEventSource', WPFC.ajaxurl);
                    //calendar.fullCalendar('addEventSource', {url : WPFC.ajaxurl, allDayDefault:false, ignoreTimezone: true, data : WPFC.data});
                    //calendar.fullCalendar( 'refetchEvents' );    // refresh calendar events
                });
    
    calendar.fullCalendar( 'refetchEvents' );    // refresh calendar events
    
    });

    is there a way to apply the filter ‘wpfc_fullcalendar_args’ in ajax?

    Please, please help!!

    https://wordpress.org/plugins/wp-fullcalendar/

Viewing 1 replies (of 1 total)
  • Was there ever a solution to this? I’m struggling to find a way to add my own meta kvp to the $args for the WP Query in their AJAX call.

Viewing 1 replies (of 1 total)
  • The topic ‘Ajax Refetch events with wpfc_fullcalendar_args’ is closed to new replies.