Home › Forums › Calendar Products › Events Calendar PRO › Problems with Venues and Organizer MetaBox
- This topic has 11 replies, 2 voices, and was last updated 8 years, 11 months ago by
David.
-
AuthorPosts
-
May 12, 2017 at 4:39 am #1282862
David
ParticipantHi, I need to create a custom meta box for saving the information of Organizers and Venues. I’ve already removed the Events Calendar default section of organizer and venue post types by editing the admin-views > events-meta-box.php. Is there another way to accomplish that in a more secure way to prevent interventions when there will be future plugin updates?
Then, I created a new meta box using metabox.io plugin and assigned _EventOrganizerID and _EventVenueID values to the new fields. The problem is that when post save occurs, no data is stored within protected custom fields. Could you tell me what do I need to do to solve this issue?
Thanks
May 12, 2017 at 9:54 am #1283156Cliff
MemberHi, David.
We’re always glad to hear about interesting customizations. However, we cannot provide such in-depth customization help, per our Scope of Support / Terms. I can try to point you in the right direction, though.
- Could you please explain the use case for needing to do this? It might provide some helpful context.
- Organizers and Venues are just custom post types so any sort of post selection tool/library should work if you tell it which post type to filter for.
- Please explain what you mean by “protected” custom fields. Are you thinking our plugin is somehow protecting its custom fields? If yes, then that’s incorrect; they’re just regular WordPress custom fields. You can see how the data is stored by looking in your database’s postmeta table for an Event post type.
Note: if you need some coding help, you may want to ask your developer or reference our documentation and list of known customizers.
May 12, 2017 at 10:31 am #1283185David
ParticipantHi Cliff, thanks for your information!
Regarding point 1, I need to organize the event creation in the backend in different meta-boxes in a way that it makes clear that all information about one thing (like Organizer) is all grouped in the same place (so, an “Organizer” meta-box that contains both your default fields and new custom ones).
To do this, I deleted the Venue and Organizer default fields from events-meta-box.php and created new meta-boxes using metabox.io.The problem is this: when, in the new meta-box, I use _EventOrganizerID or _EventVenueID to save the custom field, it doesn’t save (or add) it. But, if I change the ID, everything works fine and the custom field is saved.
So, I immagine that there is a hook somewhere in the plugin that prevents the custom field to be saved with _EventOrganizerID or _EventVenueID outside your meta-box. What can I do to solve this problem?Thank you!!
May 12, 2017 at 3:30 pm #1283314Cliff
MemberI’m not familiar with metabox.io, but could you please provide your code snippet that saves the post data?
May 12, 2017 at 5:07 pm #1283337David
ParticipantThis code shows the meta-box and loads the information of the organizer’s post type inside the filed, but when saving the page nothing is added to the custom fields list. If I change the ID “_EventOrganizerID” with something else, instead, the value is added.
<?php add_filter( 'rwmb_meta_boxes', 'register_meta_boxes' ); function register_meta_boxes( $meta_boxes ) { $meta_boxes[] = array( 'id' => 'events_roles', 'title' => __( 'Roles', 'uplift' ), 'post_types' => array( 'tribe_events'), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array( array ( 'name' => esc_html__( 'Organizer(s)', 'uplift' ), 'id' => "_EventOrganizerID", //ID defined by tribe_events 'type' => 'post', 'post_type' => 'tribe_organizer', 'field_type' => 'select_advanced', 'multiple' => true, 'query_args' => array('post_status' => 'publish',), 'placeholder' => esc_html__( 'Select Organizer(s)', 'uplift' ), ), ) ); return $meta_boxes; }May 14, 2017 at 8:11 pm #1283720Cliff
MemberCouple notes:
- You should useTribe__Events__Main::POSTTYPE instead of ‘tribe_events’ and Tribe__Events__Main::ORGANIZER_POST_TYPE instead of ‘tribe_organizer’
- Similarly, you should use Tribe__Events__Linked_Posts::instance()->get_meta_key( Tribe__Events__Main::ORGANIZER_POST_TYPE ) instead of ‘_EventOrganizerID’
- I didn’t see in their documentation if ‘type’ => ‘post’, saves the data as the Post ID, but I assume it does. I’d suggest getting the postmeta from your database for an Event (or whatever post type you’re using this metabox for) and then run your code and then save an entry and see what the before vs. after of postmeta for this Post ID looks like.
Please let me know what your before vs. after looks like if you can. (A screen capture video is just fine too if you’d like.)
May 17, 2017 at 10:01 am #1285059David
ParticipantThis reply is private.
May 17, 2017 at 3:18 pm #1285183Cliff
MemberI’m glad you’re making progress.
From your 2nd screenshot, it appears ‘id’ would get set to a string and not an integer. See https://github.com/moderntribe/the-events-calendar/blob/4.5.1/src/Tribe/Linked_Posts.php#L145-L164
May 18, 2017 at 1:35 am #1285346David
ParticipantHi Cliff,
Thank you for your answer!
I’m not really understanding how to change che id from string to integer and why the id should be an integer. Is this the cause of the warning?Could you help me to understand how and where to intervene, please?
Thanks,
DavidMay 18, 2017 at 3:08 pm #1285888Cliff
MemberSorry, I got WordPress’ typical “id” naming (usually an integer) confused with this being specific to https://metabox.io/docs/registering-meta-boxes/, where the example shows it is a string.
You should reference:
- KB article about Linked Posts: https://theeventscalendar.com/knowledgebase/abstract-post-types/ (just a good reference, may not apply for this use case)
- The start of the 2 lines mentioned in your errors: https://github.com/moderntribe/the-events-calendar/blob/4.5.1/src/Tribe/Linked_Posts.php#L58
- What may be missing from your customized version of this file (and therefore throwing those 2 errors): https://github.com/moderntribe/the-events-calendar/blob/4.5.1/src/admin-views/events-meta-box.php#L170
Please let me know what you discover.
June 9, 2017 at 9:35 am #1295829Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Problems with Venues and Organizer MetaBox’ is closed to new replies.
