Make a specific Calendar catagory private

Home Forums Calendar Products Events Calendar PRO Make a specific Calendar catagory private

Viewing 15 posts - 16 through 30 (of 51 total)
  • Author
    Posts
  • #23790
    Barry
    Member

    Hi Andy! You’re perfectly correct of course – and if you want to give that a whirl (Phil) please do! You can find guidance on how to package up code as a plugin here.

    The reason I shy away from suggesting this is that past experience tells me wrapping code in a plugin in this way can be a step too far for many people – who simply want to copy and paste code into a specific location (I’m not suggesting this is the case with you Phil!).

    It’s a great idea though for those who are comfortable doing it 🙂

    #23828
    wort
    Participant

    Great idea, and something our people have been requesting. We’ve got it working for the calendar, but not the list, so far. Thank you!

    #23865

    Hey guys!

    This should do it. Please test it and let me know.
    https://gist.github.com/3415684

    #24476
    Phil
    Participant

    How would I make this into a plugin?

    #24477
    Phil
    Participant

    Er nevermind, I see the link above. How would I combine the 2 different codes from Barry and Daniel to make this work as a plugin?

    #24478

    Hey Phil, my snippet works as a plugin.

    You just need to add the plugin header (http://codex.wordpress.org/Writing_a_Plugin) and place it in wp-content/plugins/

    Why do you need to combine the two codes?
    Cheers!

    #24530
    Phil
    Participant

    Wasn’t sure if your snippet did both or if it needed to be combined with what Barry originally posted.

    #24531
    Barry
    Member

    Yep Daniel’s code is the best choice here 🙂

    And if you can wrap it up as a plugin you’ll be all set! Let us know if you need any further help.

    #24533
    Phil
    Participant

    OK, I think I typed up the plugin properly. When I uploaded it to my site and try it out I get the following warning and the event doen’t show on the calendar, even if I am logged in….

    Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/allsaintsmedia/fred_pres/wp-content/plugins/Events_Calendar-Private_event.php_/Events_Calendar-Private_event.php on line 35

    #24534
    Phil
    Participant

    Here is my code…

    TribeEvents::TAXONOMY,
    ‘field’ => ‘slug’,
    ‘terms’ => array( ‘private’ ),
    ‘operator’ => ‘NOT IN’ );

    /*
    * The we merge our new tax_query with the
    * original one, so we don’t loose any category
    * filter we may need to use in the Front End
    */

    $taxquery = array_merge( $taxquery, $query->tax_query->queries );

    /*
    * And at the end we add the new resulting tax_query
    * to the main events query, _before_ said query
    * so we don’t need to traverse the whole results
    * and delete the events we don’t want to show.
    *
    * This is the equivalent of using pre_get_posts
    * to filter things out in the standard WordPress
    * way
    *
    */

    $query->set( ‘tax_query’, array( $taxquery ) );

    return $query;
    }

    #24535

    Phil, can you post your code in http://pastebin.com/ and post here the link?

    Thanks

    #24536
    Phil
    Participant
    #24537
    Phil
    Participant
    #24539

    Interesting. Your plugin doesn’t fail for me.

    Where are you seeing that notice exactly?

    #24540
    Phil
    Participant

    I changed your hidden slug to private because that is the slug for my Private category. When I upload the plugin, then create an event and use the Private event category, when I update or publish the event I get that warning and then the event doesn’t appear on the calendar, even if I am logged in. It does however show in the backend list of events.

    here is the link to the site being developed
    http://fredpres.allsaintsmedia.com/events

Viewing 15 posts - 16 through 30 (of 51 total)
  • The topic ‘Make a specific Calendar catagory private’ is closed to new replies.