Skip Navigation

[Résolu] Events Manager: Default Layout for user-submitted events

This support ticket is created Il y a 6 années et 11 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Marqué : 

This topic contains 2 réponses, has 2 voix.

Last updated by webD-3 Il y a 6 années et 11 mois.

Assisted by: Minesh.

Auteur
Publications
#519561
webd3-recurring-event-template-layout-not-assigned.jpg

Very similar problem to the one explained here:
https://toolset.com/forums/topic/bind-posts-to-content-template-after-changes/

It's not exactly the same, however, due to either changes in one or both plugins, or due to my setup being not exactly the same as the original poster.

In my case, I am having the same problem with Recurring Events, except that I need a Layout assigned rather than a Content Template. I have tried modifying the function offered as a solution in the above link, but have not found the proper combination to make it work.

My screenshot looks almost exactly the same as the above link except that I am trying to assign a "Template Layout" instead of a "Content Template." What should the function look like to make this work when new events are submitted from the Events Manager front-end form?

#519683

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I can see you are using layouts so as you are using layouts you should create the layout for this post type and assign your post type to use this layout.
=> https://toolset.com/documentation/user-guides/benefits-of-templates-for-custom-types-layouts/

Now - after creating and assigning the layout - if you still see that after creating the event from front end the layout is not assigned then you should use following code:

add_post_meta($post_id, '_layouts_template', 'SLUG-NAME-OF-LAYOUT-TO-USE', true);

We store layout name in postmeta table with meta key = '_layouts_template' and you should assign value of your assigned layout slug.

#519966

Minesh,

Thank you. I've now got this working thanks to your help.

'add_post_meta', rather than 'update_post_meta' from the example in the other support thread I linked, was half of the solution.

The other half was using 'event-recurring' rather than 'event' for the post type. This doesn't have anything to do with you, rather the Events Manager plugin, but was vital to the solution as well.

Here's what the successful code looks like, for anyone else that might be in my situation in the future...

add_action( 'save_post', 'assign_layout_to_recurring_events', 100 );
function assign_layout_to_recurring_events( $post_id ) {
        if ( get_post_type( $post_id ) != 'event-recurring' ) {
                return;
        }
        $template = get_post_meta( $post_id, '_layouts_template', true );
        if ( empty( $template ) ) {
                add_post_meta( $post_id, '_layouts_template', 'SLUG-NAME-OF-LAYOUT-TO-USE', true );
        }
}
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.