Get events by username

Home Forums Calendar Products Events Calendar PRO Get events by username

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1210534
    Aaron
    Participant

    Hi ,
    I would like to generate a URL with username , from where I can get the events of that particular user and list them .

    Let me know how can i got this .

    Thanks.

    #1210591
    Nico
    Member

    Hey Aaron,

    Glad to help you out on this issue as well 🙂

    You can use WordPress default author templates for this. Once those are setup you can use the following shortcode to get current user events (please note this will only work in author pages): [tribe_get_current_user_events].

    To enable the shortcode add the code below to your theme’s (or child theme’s) functions.php file:

    // Tribe, [tribe_get_current_user_events] shortcode to get current user upcoming events
    function tribe_get_current_user_events_func( $atts ){

    $output = '';

    $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));

    if ( !empty($curauth) ) {

    // more information on tribe_get_events: https://theeventscalendar.com/knowledgebase/using-tribe_get_events/
    $events = tribe_get_events( array(
    'author' => $curauth->ID,
    ) );

    $output = '

      ';
      foreach ( $events as $post ) { setup_postdata( $post );

      $output .= '

    • ';
      $output .= $post->post_title . ' - ' . tribe_get_start_date( $post );
      $output .= '
    • ';

      }
      $output .= '

    ';

    }

    return $output;
    }
    add_shortcode( 'tribe_get_current_user_events', 'tribe_get_current_user_events_func' );

    If you are going to use this in a php template, you can execute the shortcode using:


    Please let me know if this helps,
    Best,
    Nico

    #1210655
    Aaron
    Participant

    Hi Nico ,

    I want to to make a feature Gym at home page and on its detail page I want its all events listing .
    So I want to generate a URL like http://nischayapps.com/dev/fresh/organizer/aaron/ , here you set up URL for organizer , same I want for particular user events.

    Thanks.

    #1211161
    Nico
    Member

    Thanks for following up Aaron! Sorry to say I’m not quite following you here.

    Can you describe a bit more what you are looking forward to achieve? You want to replicate the organizer page, but for users? If that’s the case, I don’t think that can be super straight forward. You’d need to replicate the organizer template and functions (events-calendar-pro/src/views/pro/single-organizer.php) inside the author template and ‘patch’ the information by getting it from the user object and not from the organizer. Just to clarify organizers are not WordPress users, it uses a custom post type linked to products (like venues), so porting this same view for users will require a bit of work from your side.

    Please let me know about it,
    Best,
    Nico

    #1220976
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Get events by username’ is closed to new replies.