Home › Forums › Calendar Products › Community Events › Limit fields to edit once published, community
- This topic has 5 replies, 3 voices, and was last updated 10 years, 2 months ago by
Support Droid.
-
AuthorPosts
-
January 25, 2016 at 3:43 am #1061522
James
ParticipantHi,
I am making a website for our village and are using your pro and community plugins.
I was wondering if it is possible to limit the fields that can be edited after a post has been published for community events, currently if a admin publishes a user’s event then the user can go in and change anything they want. I am fine with them changing the description and title etc but would like to prevent them from editing the date and time as a lot of the events will be using the communal village hall so times can only be changed after checking with the bookings secretary, who is an admin and will log in and change the event details for them.
I did think about removing the inputs from the form, or just changing the visibility to none for the ones I don’t want to show but the event creation and edit form seem shared so was unsure how to do this.
Another solution could be to change the event to a draft again after the user edits someone, again I’m unsure how to do that.
Any help would be much appreciated.
Thanks
James
January 26, 2016 at 2:05 pm #1062714Nico
MemberHi James,
Thanks for reaching out to us, and sorry for my delayed reply. I’m looking into the issue and trying to find the simplest approach to solve this, but it’s getting a little tricky!
Just wanted to give you a quick heads up on this. I’ll be updating the thread soon!
Best,
NicoJanuary 26, 2016 at 2:33 pm #1062726Nico
MemberHey James,
Thanks for your patience while I looked into this!
I figured out the best way to do this would be to create a template override for the edit-event.php template (located at wp-content/plugins/the-events-calendar-community-events/src/Tribe/views/) and add the following function to use in conditionals later on the template:
...
function is_edit_page ( ) {
global $post;
return is_a ($post, 'WP_POST');
}if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
...
So for example let’s say you want to hide the date ‘part’ of the form if the user is editing, then you can do the following:
...
<?php if ( !is_edit_page() ) : ?>
<?php tribe_get_template_part( 'community/modules/datepickers' ); ?>
<?php endif; ?>
...
Please let me know if this makes sense to you and if you can make it work,
Best,
NicoJanuary 27, 2016 at 1:49 am #1062864James
ParticipantHi,
Thankyou for your response that seems like a good way of doing it and I will give it a try!
After talking with my client about this they think it might be better to allow editing of certain fields (which your code should achieve) but also set the event as a draft again after it has been edited so an admin has to approve it. Do you have any idea how this could be achieved? I know there is an option to set whether community events are submitted as drafts or as published, so was thinking I could create an override that checks if the form is the edit form, and if so will submit the event as a draft instead of published.
I appreciate your help as I’m aware I’m not using the plugin quite as intended!
Thanks,
James
January 27, 2016 at 12:39 pm #1063383Nico
MemberJames,
Glad you find that approach useful!
…also set the event as a draft again after it has been edited so an admin has to approve it. Do you have any idea how this could be achieved?
Sure! You’ll need to add the following snippet to your theme (or child theme) functions.php file:
/*
* The Events Calendar - Allways set to draft CE form sumissions
*/
add_action( 'tribe_community_event_updated', 'ce_set_draft' );
add_action( 'tribe_community_event_created', 'ce_set_draft' );function ce_set_draft ( $event_id ) {
$current_post = get_post( $event_id, 'ARRAY_A' );
$current_post['post_status'] = 'draft';
wp_update_post($current_post);
}
Please let me know if that works for you,
Best,
NicoFebruary 20, 2016 at 8:35 am #1078926Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Limit fields to edit once published, community’ is closed to new replies.
