Hiding and/or Showing Specific Event Categories

Home Forums Calendar Products Events Calendar PRO Hiding and/or Showing Specific Event Categories

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #944792
    Victoria
    Participant

    Ok, so I hid our internal categories via the code provided at:

    https://theeventscalendar.com/knowledgebase/hide-category-from-calendar-views/

    That works great. But, I need to be able to show a calendar with the internal/private categories to the staff – either via role/credentials or a PW-protected page.

    The code provided in the link above is basically a global block on viewing the specified categories.

    How can I hide certain cats from the public while still being able to show all cats to the staff?

    Most other plugins use a shortcode with either a exclude=”1, 6, 14″ or a include=”2, 3, 4, 5″ param. Obviously, it wont be that simple with ECP. I just need a non-global way to do one or the other.

    Any ideas?

    Thanks!

    #944951
    George
    Participant

    Hey Raymond,

    I’m glad that knowledgebase article helped you get started with this! To truly get this working as you hope, as far as I can tell, you should be able to basically just keep the code you found there but then wrap it in a conditional check against what permissions the current user has.

    So, for example, if your staff User Roles all have the edit_post capability, you could use WordPress’ current_user_can() function to prevent the category-hiding from happening if one of those users is logged in. I made a quick, un-tested example of this for you in this Gist here → https://gist.github.com/momnt/a0e17885b7a54f8bea3c

    I did not test that code, but it should hopefully at least give you an idea of what to do here and give you a good place to start from.

    To learn more about what capabilities to check and what capabilities come with the various User Roles your staff might have, check out this article on the WordPress codex → http://codex.wordpress.org/Roles_and_Capabilities

    You could even just white-list certain user IDs that belong to your Staff Members, and just check against those IDs instead…

    Just some ideas, play around with things and keep backups of all your original code and any custom code you experiment with!

    Let us know if this helps 🙂

    Cheers,
    George

    #944992
    Victoria
    Participant

    You guys rock! Thanks.

    #945170
    George
    Participant

    Thanks for the kind words Raymond! I hope this helps you out. Play around with it, keep backups of everything just for some added security, and if you think of, select a reply here as the “Correct Answer” (you can see that link by hovering over the specific reply) if the code does, in fact, solve this for you.

    For now, I’ll close up this ticket. Don’t hesitate to open another one if other questions or concerns arise.

    Cheers!
    George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Hiding and/or Showing Specific Event Categories’ is closed to new replies.