Only display events of current user

Home Forums Calendar Products Events Calendar PRO Only display events of current user

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #25709
    Kyle
    Participant

    Is there someway to filter the calendar/grid-view to only display the events of the current user?

    #25753
    Jonah
    Participant

    Hi Kyle,

    This might be possible by using pre_get_posts like so but you’ll need to figure out the specific logic to check for the current user:

    add_action( 'pre_get_posts', 'show_posts_for_user' );
    function show_posts_for_user( $query ) {
    //if were on the gridview/calendar
    if ( $query->query_vars['eventDisplay'] == 'month' && $query->query_vars['post_type'] == TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) {
    $query->set('author', 1);
    }
    return $query;
    }

    You would place that in your themes functions.php file and change the author to whatever you want. More on the author parameter can be found here: http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters

    I hope that helps!

    – Jonah

    #25755
    Kyle
    Participant

    Thanks for your help, this will definitely get me going in the right direction. I decided to limit the view of the calendar to people who have the option to be organizers, so I may try to sort by that as the ‘author’ also.

    #25757
    Jonah
    Participant

    Awesome, glad that helped. Let me know if you need anything else.

    – Jonah

    #977852
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Only display events of current user’ is closed to new replies.