Home › Forums › Calendar Products › Events Calendar PRO › Get events by username
- This topic has 5 replies, 4 voices, and was last updated 7 years, 3 months ago by Aaron.
-
AuthorPosts
-
December 25, 2016 at 10:45 pm #1210534AaronParticipant
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.
December 26, 2016 at 11:34 am #1210591NicoMemberHey 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 = '
- ';
- ';
$output .= $post->post_title . ' - ' . tribe_get_start_date( $post );
$output .= '
foreach ( $events as $post ) { setup_postdata( $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,
NicoDecember 26, 2016 at 8:46 pm #1210655AaronParticipantHi 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.
December 28, 2016 at 11:07 am #1211161NicoMemberThanks 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,
NicoJanuary 19, 2017 at 8:35 am #1220976Support DroidKeymasterHey 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 - ';
-
AuthorPosts
- The topic ‘Get events by username’ is closed to new replies.