Select Events by Author

This topic contains 11 replies, has 3 voices, and was last updated by  Vladislav Gherciu 9 years, 11 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #13234

    Hi there, is there any possibility to easily get a calendar or event list just for one author? I.e. if I post as a registered user with a certain username, can this be filtered?

    Thanks in advance, best Frank

    • This topic was modified 10 years, 4 months ago by  Frank Herget.
    Frank Herget
    #13257

    Hi Frank,

    This isn’t currently possible for the calendar. However I’ll look into this for a future update.

    As for the event list shortcode, you can do:

    [eo_events author="{ID}"]

    where ID is replaced by the ID of the user. Alternatively you can use author_name instead of author to use the author’s nicename.

    Stephen Harris
    #13258

    Hi Stephen,

    sounds great – meanwhile I managed it to get me the data sorted by author by writing an own function. Yet this update would be highly appreciated.

    Thanks a lot for pointing out the solution on the shortcode 🙂

    keep up the good work,
    cheers
    Frank

    Frank Herget
    #15178

    Just an update to say that as of Event Organiser 2.12.0 (to be released shortly) you can do the following:

    [eo_fullcalendar author=<user-id>]
    

    or

    [eo_fullcalendar author_name=<user-nicename>]
    

    to display a calendar of a particular user’s events.

    Stephen Harris
    #15199

    Hello Stephen,

    thanks a bunch for the update 😉 Comes in handy.

    cheers
    Frank

    Frank Herget
    #15872

    Looks great,

    I cannot seem to have it show the logged-in user events, does the author have to be hardcoded?

    Thanks
    Vlad

    Vladislav Gherciu
    #15873

    That is the case currently. There are two ways around this. Define a shortcode which just a wrapper for [eo_fullcalendar], but sets the author ID as appropriate.

    Alternatively (and perhaps preferably) is to use the shortcode_atts_* filter (WP 3.6.0+):

     add_filter( 'shortcode_atts_eo_fullcalendar', 'my_fullcalendar_filter', 10, 3 );
     function my_fullcalendar_filter( $atts, $defaults, $provided_atts ){
    
         //If you preferred, you could check $provided_atts['author'] for a 
         //placeholder, e.g. %current_user_id% and replace that with the current 
         //user ID. Then do [eo_fullcalendar author=%current_user_id%]
         if( is_user_logged_in() ){
               $atts['author'] = get_current_user_id();
         }
    
         return $atts;
     }
    

    I won’t rule out supporting this in a future update, but the above example shouldn’t cause any problems should a current user placeholder be introduced.

    Stephen Harris
    #15874

    That is the case currently. There are two ways around this. Define a shortcode which just a wrapper for [eo_fullcalendar], but sets the author ID as appropriate.

    Alternatively (and perhaps preferably) is to use the shortcode_atts_* filter (WP 3.6.0+):

     add_filter( 'shortcode_atts_eo_fullcalendar', 'my_fullcalendar_filter', 10, 3 );
     function my_fullcalendar_filter( $atts, $defaults, $provided_atts ){
    
         //If you preferred, you could check $provided_atts['author'] for a 
         //placeholder, e.g. %current_user_id% and replace that with the current 
         //user ID. Then do [eo_fullcalendar author=%current_user_id%]
         if( is_user_logged_in() ){
               $atts['author'] = get_current_user_id();
         }
    
         return $atts;
     }
    

    I won’t rule out supporting this in a future update, but the above example shouldn’t cause any problems should a current user placeholder be introduced.

    Stephen Harris
    #15879

    Thanks Stephen, I used [eo_fullcalendar author=%current_user_id%] shortcode and it worked.

    Vladislav Gherciu
    #15880

    Just one small clarification:

    The snippet you inserted above, should It be added to the functions.php from the EO package?

    Thanks
    Vlad

    Vladislav Gherciu
    #15881

    No, ideally a utility package, but a theme’s functions.php will work. (See this page for details).

    Stephen Harris
    #15882

    Thanks Stephen, again very helpful =]

    Managed to sort this one out

    Vlad

    Vladislav Gherciu
Viewing 12 posts - 1 through 12 (of 12 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.