Home › Forums › Calendar Products › Community Events › Specific users not blocked from adding events
- This topic has 5 replies, 2 voices, and was last updated 10 years, 1 month ago by Casey.
-
AuthorPosts
-
February 13, 2014 at 3:31 pm #104288ceramofilesParticipant
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!
February 14, 2014 at 12:34 pm #104592CaseyParticipantceramofiles,
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/9008700NOTE: 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-
February 15, 2014 at 10:23 am #104982ceramofilesParticipantThanks 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!
February 17, 2014 at 6:20 am #105315CaseyParticipantSo 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!
February 17, 2014 at 9:21 am #105449ceramofilesParticipantGreat! 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!
February 17, 2014 at 9:27 am #105453CaseyParticipantGreat! 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-
-
AuthorPosts
- The topic ‘Specific users not blocked from adding events’ is closed to new replies.