Home › Forums › Calendar Products › Community Events › Frontend Editing of ALL community events
- This topic has 5 replies, 2 voices, and was last updated 10 years, 4 months ago by
Brook.
-
AuthorPosts
-
December 2, 2015 at 4:55 am #1033627
Sascha
ParticipantHi guys,
happy customer of the PRO version with community add-on. We use the system in a controlled intranet environment. The community events are added by internal guys without login for convenience reasons. As there are mistakes sometimes we would like to have one person with admin/editor capabilities to fix errors and stuff. However it would be best not to have people in the backend (really low tech users). Is ist possible to have an frontend edit button for certain user roles on ALL events or have a certain link to enable them to edit also events that have been posted by others?
Thanks for your input
Sascha
P.S.: A solution could be to auto assign events with no author to the “admin” user. ?!? Is there a hook for this?
-
This topic was modified 10 years, 4 months ago by
Sascha.
December 2, 2015 at 10:39 am #1033977Brook
ParticipantHowdy Sascha,
That is absolutely possible. It will require a little bit of theming and PHP, but if you are even somewhat comfortable with such things then you could add this feature. The steps:
- Create a theme override for the single-event.php file by following our themer’s guide.
- Inside that file add a link anywhere you want. If I were you this is the PHP I would use:
if ( current_user_can('edit_others_posts') ) { echo '<a href="/events/community/edit/event/'.get_the_ID().'">Edit</a>'; }That will show an edit link to the current page, but only if the user even has the capability to edit it.
Does that all make sense? Would that work for you?
Cheers!
- Brook
December 3, 2015 at 1:39 am #1034337Sascha
ParticipantHey Brook,
that is awesome! Works as expected! 🙂
Just one more thing. Would it also be possible to add a “Delete” Link? what would be the url to add?
Cheers Sascha
December 3, 2015 at 10:28 pm #1035226Brook
ParticipantHowdy Sascha,
The bare URL would just be:
'/events/community/delete/'.get_the_ID()However, for security reasons it uses a wp_nonce. So you would to add a nonce to the bare URL:Â https://codex.wordpress.org/WordPress_Nonces
Without the nonce it will say “you don’t have permission to perform this action” and generate an error.
Cheers!
– Brook
December 4, 2015 at 12:31 am #1035262Sascha
ParticipantThanks for hinting me to the right direction! 😉
I modified your links with the allready existing functions/classes:
<?php if ( current_user_can('edit_others_posts') ) { $post = get_post(get_the_ID()); echo Tribe__Events__Community__Main::instance()->getEditButton( $post, __( 'Edit', 'tribe-events-community' ), '<span class="edit wp-admin events-cal"> |', '</span> ' ); } if ( current_user_can('delete_others_posts') ) { echo Tribe__Events__Community__Main::instance()->getDeleteButton( $post ); } ?>Works great! Thanks!!!
Sascha
December 8, 2015 at 2:17 am #1037364Brook
ParticipantExcellent! Thanks for sharing the code, it’s simply beautiful.
Please let us know if you ever need anything else. Cheers!
– Brook
-
This topic was modified 10 years, 4 months ago by
-
AuthorPosts
- The topic ‘Frontend Editing of ALL community events’ is closed to new replies.
