Hiding specific event category when user is not logged in

Home Forums Calendar Products Events Calendar PRO Hiding specific event category when user is not logged in

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #86924
    Craig Moser
    Participant

    Currently in search of a function to hide individual categories when someone is not logged in. In my case I need category ‘schedule’ to only show when a member is logged in and not viewable to the public.

    #88612
    Brook
    Participant

    Howdy cmoser13,

    First of all I am very sorry for the belated response. We launched an update to our forum recently and in the shuffle your post was lost.

    Some users have been able to accomplish what you want through a quick CSS hack. Simply adding a style like the following if a user is not logged in:

    .tribe-events-category-schedule{display:none;}

    There are a few functions WP provides for detecting if a user is logged in, or what permissions they have. If you simple want to see if they are logged in, is_user_logged_in() works great. If you want to instead only show the schedule to say admins, this would be a better fit: current_user_can(‘administrator’). Simply display that CSS when one of these functions returns true, and you are set!

    Of course a CSS hack does not truly hide your schedule from search engines or saavy users. If you want to fully hide these events you will need to modify the queries. This will definitely require a good knowledge of WP queries and hooks. You would want to hook into our queries and then filter out that category. Tribe Query documentation is a good place to get started if you wish to go this route. Especially when viewing the class file itself will you see some available hooks and examples for limiting queries. Obviously you would want to put all this logic inside of one of the WP user capability conditionals I linked to in the last paragraph.

    Will that work for you? Thanks for posting. Again, truly sorry about the delay.

    – Brook

     

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Hiding specific event category when user is not logged in’ is closed to new replies.