Forum Replies Created

Viewing 9 replies - 31 through 39 (of 39 total)
  • Plugin Author Marc Bellêtre

    (@marcbelletre)

    Hi @florushj,

    Thank you for the feedback. I’m glad you found a way ??

    I thought you were only looking for a way to query future events. I didn’t understand you were trying to show every date in an agenda style.
    I have worked on multiple projects with the exact same use case and made it work like you did. I could have send you the code I’m using if I knew.

    I know it’s a bit cumbersome but this plugin can only provide a field that you can use on any custom type so the implementation is up to you.

    Maybe if I have some time I could write a small documentation with implementation examples like this one.

    Cheers,
    Marc

    Plugin Author Marc Bellêtre

    (@marcbelletre)

    Hi,

    This plugin only provides an ACF field for creating recurring dates with a convenient user interface. If you need to manage events you will have to create your own custom post type.

    I’m not sure what you want to do exactly but this plugin is not going to help you with push notifications.

    Plugin Author Marc Bellêtre

    (@marcbelletre)

    Thank you very much for this lovely feedback ??

    Cheers!

    Plugin Author Marc Bellêtre

    (@marcbelletre)

    Hi guys,

    Sorry for the very long delay, I’ve been quite busy for a while and I couldn’t find time to get back to you.

    @florushj what I told you about the start_date and end_date being set automatically by the plugin was actually wrong. I didn’t remember that I wrote a function that set these values but this function is not part of the plugin. Sorry for the mistake.

    If that can still help here is a function you can use to set these dates when saving a post:

    
    /**
     * Custom actions when an event is saved.
     *
     * @param  int  $post_id
     * @return void
     */
    function my_post_saved($post_id)
    {
        if (!$post_id || get_post_type($post_id) !== 'event') {
            return;
        }
    
        $dates = [];
        $recurrence = get_field('recurrence', $post_id);
    
        foreach ($recurrence['dates_collection'] as $date) {
            if (!in_array($date->format('Y-m-d'), $dates)) {
                $dates[] = $date->format('Y-m-d');
            }
        }
    
        // Sort dates
        sort($dates);
    
        // Update start and end dates in post meta
        update_post_meta($post_id, 'start_date', $dates[0]);
        update_post_meta($post_id, 'end_date', $dates[count($dates) - 1]);
    }
    add_action('acf/save_post', 'my_post_saved');
    

    Hope this helps!

    Plugin Author Marc Bellêtre

    (@marcbelletre)

    Hi @florushj,

    Thank you for the kind feedback ??

    The plugin automatically sets a start_date and a end_date post meta when saving the field. So you can basically get all the future events by adding the following meta_queries: you want to retrieve all events that started before the end date (1 month after the start date), and that will end after the start date.

    $start = new DateTime();
    
    // Set the end date to the next month (or use 'P1W' for the next week)
    $end = clone $start;
    $end->add(new DateInterval('P1M'));
    
    // Set both dates to midnight
    $start->setTime(0,0,0);
    $end->setTime(0,0,0);
    
    new WP_Query([
        'post_type' => 'event',
        'posts_per_page' => -1,
        'post_status' => 'publish',
        'meta_query' => [
            'relation' => 'AND',
            [
                'key' => 'start_date',
                'compare' => '<=',
                'value' => $end->format('Y-m-d'),
                'type' => 'DATE',
            ], [
                'key' => 'end_date',
                'compare' => '>=',
                'value' => $start->format('Y-m-d'),
                'type' => 'DATE',
            ],
        ],
    ]);

    Hope this helps ??

    Cheers,
    Marc

    Forum: Plugins
    In reply to: [ACF RRule Field] Usage
    Plugin Author Marc Bellêtre

    (@marcbelletre)

    Hi,

    I don’t know about Oxygen Builder but if you can write PHP code you would just have to use get_field('field_name') (replacing field_name by the actual name of your RRule field) to return the generated set of dates. You can read more here: https://github.com/marcbelletre/acf-rrule#usage

    You can use this plugin to add RRule fields inside repeaters. I actually use it a lot this way ??

    Thread Starter Marc Bellêtre

    (@marcbelletre)

    Hi Edson,

    Thank you for the quick answer.

    We actually figured it out. We were using the language switcher inside a menu created through Appearance > Menus and we had a custom nav walker to add the bootstrap classes to the menu. Removing the walker and switching back to the original WordPress menu fixed the issue.

    It had nothing to do with our multisite setup.

    Sorry for wasting a bit of your time!

    Cheers,
    Marc

    Plugin Author Marc Bellêtre

    (@marcbelletre)

    Hi @cyclic,

    A similar issue was created on Github a few days ago. I finally figured out how to reproduce the error (it happened only with the classic editor).

    The bug has been fixed and the whole validation process has been improved. I mark this issue as resolved but don’t hesitate to reopen if needed.

    Cheers!

    Plugin Author Marc Bellêtre

    (@marcbelletre)

    Hi @cyclic,

    Sorry for the delay, I’ve never been notified about this bug report. I can’t reproduce the error here. Everything seems to work fine when using conditional logic on the RRule field. I tried using a true/false field and showing the RRule field when the box is checked, with the RRule field set as required. I was able to save my post without any validation error.

    Could you please tell me which versions of ACF and ACF RRule Field you are using?

    Thanks!

Viewing 9 replies - 31 through 39 (of 39 total)