WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Recurring Events and ACF (20 posts)

  1. afreyer
    Member
    Posted 1 year ago #

    hi,

    i tried to use EM with Advanced Custom Fields Plugin - for a event entry, it works fine. But if i want manage fields in recurring events, it seems to has no impact. Anybody who has experience with it?

    http://wordpress.org/plugins/events-manager/

  2. FranceImage
    Member
    Posted 1 year ago #

    Hello,

    Can you tell more about what behaviour you expect ?

    I had a look and it seems to work as I expected.
    If you define a custom field for event you will find it when editing the event.
    If you define a custom field for a recurring event, you will find it when editing the recurring event but not when you edit the instances of this recurring event. Instead (on the instance) you will see the custom field you defined for event.

    In other words, EM does not propagate recurring event custom fields when creating the instances.

    Does it make sense ?

  3. afreyer
    Member
    Posted 1 year ago #

    thank you. yes, i want to setup custom fields in a recurring event. so events of this recurring term will have the same configuration. but it doesnt work..is there a solution? i do not want to setup the several event..

  4. angelo
    NetWebLogic Support
    Posted 1 year ago #

    sorry, can't give you an advice with regards to integrating the two plugins since I haven't tried it yet.

  5. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    hard to say without diggging into the way ACF is saving custom fields, but EM should replicate all the custom post fields belonging to an event.

  6. afreyer
    Member
    Posted 1 year ago #

    @FranceImage:

    In other words, EM does not propagate recurring event custom fields when creating the instances.

    Ok, i understand. both types are several things.
    with thumbnails i have the same problem.
    but is it possible to transform custom fields of recurring event to cf of several event? maybe the same way for thumbnails?

  7. FranceImage
    Member
    Posted 1 year ago #

    Hello,

    I searched a bit more and I found out I overlooked the problem.

    In em-event.php (save_events()) there is code to propagate the postmeta.
    However, EM creates the events while saving the recurring event.
    This means that the recurring event (ACF) postmeta are not yet saved when EM creates the events (instances of the recurring event).

    I noticed that if you save the recurring event 3 times, you end up seeing your custom field in the events (provided you have configured ACF to handle it in event OR recurring-event posttype).

    BUT, if you do that, you have 3 times more events than you want.

    A bit tricky :(

  8. FranceImage
    Member
    Posted 1 year ago #

    Hello,

    I searched a bit more and I found out I overlooked the problem.

    In em-event.php (save_events()) there is code to propagate the postmeta.
    However, EM creates the events while saving the recurring event.
    This means that the recurring event (ACF) postmeta are not yet saved when EM creates the events (instances of the recurring event).

    I noticed that if you save the recurring event 3 times, you end up seeing your custom field in the events (provided you have configured ACF to handle it in event OR recurring-event posttype).

    BUT, if you do that, you have 3 times more events than you want.

    A bit tricky :(

  9. philipjohn
    Member
    Posted 1 year ago #

    The full snippet around that appears to suggest that it will only save if the recurring events has been published:

    if( $this->is_recurring() && $result && $this->is_published() ){ //only save events if recurring event validates and is published
    			 	if( !$this->save_events() ){ //only save if post is 'published'
    					$this->add_error(__ ( 'Something went wrong with the recurrence update...', 'dbem' ). __ ( 'There was a problem saving the recurring events.', 'dbem' ));
    			 	}
    			}

    I will have to defer to Marcus on this but that code suggests that isn't the issue in this particular case.

    Cheers

  10. afreyer
    Member
    Posted 1 year ago #

    workaround (it works for me)

    add recurring event -> edit -> save
    edit single event(child of this recurring e.) -> edit CF -> save

    running..

  11. afreyer
    Member
    Posted 1 year ago #

    hm, but old entries still not showing cf

  12. afreyer
    Member
    Posted 1 year ago #

    ok, i ask for a second: is it possible to transform custom fields of recurring events to custom fields of several event?

  13. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    custom fields should be copied over to recurrences, however, the ACF hooking in later presents a problem, something we might not tackle since our future plans to rewrite recurrences wold fix this automatically.

  14. afreyer
    Member
    Posted 1 year ago #

    sorry marcus, i didnt understand your answer. in future it will be possible or not?

  15. philipjohn
    Member
    Posted 1 year ago #

    It should be yes, although it won't be fixed directly. Rather, some other improvements to the way the plugin works will render this issue obsolete.

    No ETA on when that will happen though I'm afraid.

    Thanks

  16. afreyer
    Member
    Posted 1 year ago #

    ACF uses simple custom fields - i cannot understand, why it doesnt work for recurrences.
    so it makes more complicated for me, to use EM. i will try it with attributes. But in my opinion, attributes are also custom fields. am i right?

  17. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    Yes, custom attributes are stored and retrieved from the database in the same way as custom fields.

  18. afreyer
    Member
    Posted 1 year ago #

    @caimin_nwl:
    Maybe, i should contact the devlopers of ACF for a second time. It sounds like this way of managing custom fields could be the reason for it.
    @philipjohn and marcus:
    using of attributes is a build in feature of this great plugin and could (for me should) be more and more extended. because fields (type textfields in EM) of attributes are not enough. i think about radiobuttons, relations for linking to the post of several event, thumbnails, etc. pp.
    i have a dream..
    :)

  19. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    FranceImage's suggestion might be a temporary workaround, save your recurring event 3 times (I'd imagine two times would be enough).

    Since recurrences are deleted each time you save, you shouldn't end up with duplicates.

    We're seeing some similar issues with s2Member and restricting recurrent events to membership levels, so chances are fixing this will fix recurrences too.

  20. afreyer
    Member
    Posted 1 year ago #

    3 times are right. thank you.

  21. zedjasper
    Member
    Posted 12 months ago #

    I found a work around after a long time. You would need to do it every time you update the plugin.

    Replace around line #344 of the file classes/em-event.php (the else statement) with the code below.

    global $wpdb;
                $event_post_id = $this->post_id;
    		    $results = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".EM_EVENTS_TABLE." WHERE post_id=%d", $this->post_id), ARRAY_A);
                if($results['recurrence_id'] > 0){
                    $event_parent = $wpdb->get_row($wpdb->prepare("SELECT post_id FROM ".EM_EVENTS_TABLE." WHERE event_id=%d", $results['recurrence_id']), ARRAY_A);
                    $event_post_id = $event_parent['post_id'];
                }
    			$event_meta = get_post_meta($event_post_id);

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic