Home › Forums › Welcome! › Pre-Sales Questions › Frontend and backend calendar? (PART 2 .. :-) )
- This topic has 3 replies, 1 voice, and was last updated 8 years, 9 months ago by Brian.
-
AuthorPosts
-
May 25, 2015 at 11:27 am #964880Kalle PedersenGuest
Hi again,
I posted a question on May 15. Geoff answered very nicely, but I didn’t quite find, what I was searching for.
(https://theeventscalendar.com/support/forums/topic/frontend-and-backend-calendar/)
Hence my follow-up:
Hiding certain categories in the calendar is not an option as it will then hide this category for everyone.
What I am searching for is the ability to display events / categories based on user roles.
Is it perhaps possible (by shortcode or by modifying php) to display one calendar with ALL events (for the backend community users) and then to display a SECOND calendar that does not show draft events that have not yet been approved by an admin?
Again: thanks a lot for the support and I hope your nice plugin can do, what I am searching for (one way or another 🙂 )
Kind regards…
May 26, 2015 at 1:14 am #965012Kalle PedersenGuestHi again,
I’m no pro, but I managed to “get it done” with inspiration from your previous reply + a little help from google.
If anyone else needs it, this is what I added to my child theme’s “functions.php:
// Removes categories “test1” and “test2” for users not logged in
add_action( ‘pre_get_posts’, ‘exclude_events_category’ );function exclude_events_category( $query ) {
get_currentuserinfo() ; global $user_level; if ($user_level == 0) { $query->set( 'tax_query', array( array( 'taxonomy' => TribeEvents::TAXONOMY, 'field' => 'slug', 'terms' => array('test1', 'test2'), 'operator' => 'NOT IN' ) ) ); } return $query; }
This hides chosen categories for users not logged in and by creating a category called e.g. “maybe”, the community members can add to a hidden category and then change to a visible category, when they want the event to be visible to all…
May 26, 2015 at 7:34 am #965089BrianKeymasterGreat thanks for sharing this coding!
You could also look to use is_user_logged_in() to tell if a person is logged in our not:
https://codex.wordpress.org/Function_Reference/is_user_logged_in
Cheers
July 1, 2015 at 8:47 am #974161BrianKeymasterSince I haven’t heard back from you here, I’m going to go ahead and close out this thread. Feel free to start a new thread if you have further issues. Thanks! 🙂
-
AuthorPosts
- The topic ‘Frontend and backend calendar? (PART 2 .. :-) )’ is closed to new replies.