Frontend Editing of ALL community events

Home Forums Calendar Products Community Events Frontend Editing of ALL community events

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1033627
    Sascha
    Participant

    Hi 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.
    #1033977
    Brook
    Participant

    Howdy 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:

    1. Create a theme override for the single-event.php file by following our themer’s guide.
    2. 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
    #1034337
    Sascha
    Participant

    Hey 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

    #1035226
    Brook
    Participant

    Howdy 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

    #1035262
    Sascha
    Participant

    Thanks 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

    #1037364
    Brook
    Participant

    Excellent! Thanks for sharing the code, it’s simply beautiful.

    Please let us know if you ever need anything else. Cheers!

    – Brook

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Frontend Editing of ALL community events’ is closed to new replies.