Specific users not blocked from adding events

Home Forums Calendar Products Community Events Specific users not blocked from adding events

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #104288
    ceramofiles
    Participant

    I’ve selected two users types to be blocked from adding events: subscribers and another user role I created. However, neither one of these roles are blocked from adding events and the events tab shows up on their admin bar. Any leads would be very helpful!

    #104592
    Casey
    Participant

    ceramofiles,
    Sorry to hear you’re having trouble hear, but hopefully I can help. Unfortunately, the ‘Roles to Block’ section of the Community Settings is referring to blocking access to the WordPress dashboard and not the ability to submit events. So, as long as they’re a registered user, they will be able to submit events. As a workaround, you could paste the following snippet into your theme’s functions.php to redirect unauthorized users to an error page that you’d create: https://gist.github.com/ckpicker/9008700

    NOTE: Keep in mind that you’ll need to change the wp_redirect URL, along with the ‘custom_role_name’ to match yours. Give that a shot and let me know if it does the trick. Thanks! 🙂

    -Casey-

    #104982
    ceramofiles
    Participant

    Thanks for the code. This looks like the right solution; however, when I add it to functions.php, I get some kind of error. The site admin and site display a blank page and when I remove the code through ftp the site displays correctly again. I changed the role and the redirect url. Here is the exact code I used (except for the site url), perhaps there is a php error?:
    add_action( ‘wp_head’, ‘community_restrict_access’ );
    function community_restrict_access() {
    if (tribe_is_community_edit_event_page() || tribe_is_community_my_events_page()) {
    if(current_user_can(‘subscriber’) || current_user_can(‘pro_member’) {
    wp_redirect( ‘http://www.mysiteurl.com’, 301 ); exit;
    }
    }
    }

    Thanks so much for your help on this!

    #105315
    Casey
    Participant

    So sorry! I left out a parenthesis, but it’s fixed now: https://gist.github.com/ckpicker/9008700 Try it again and let me know if it does the trick. Thanks!

    #105449
    ceramofiles
    Participant

    Great! So that code made it so when those users go to the submit events page it gives them an error; however, the events tab still shows up in their admin bar and they can add events if they click events > add event. Is it possible to remove the events tab from the admin bar for only subscribers and our custom role? Thanks!

    #105453
    Casey
    Participant

    Great! Glad to hear that did the trick, and sorry again for the typo. 🙁

    Unfortunately, we don’t support removing individual items from the admin bar, but you could disable it completely for certain roles using this tutorial as a starting point. You’ll need to customize the “if” statement to match the one that you have in your functions.php file.

    Hope that helps! Just let me know if you have further questions, otherwise I’ll go ahead and close out this thread. Thanks! 🙂

    -Casey-

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Specific users not blocked from adding events’ is closed to new replies.