[eo_events] author attribute

This topic contains 4 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18973

    hi,
    I am using the following snippet to try and display a buddypress users submitted events on their profile using a custom shortcode

     function custom_shortcode(){
                 $user_id = get_the_author_meta( 'ID' ); //returns id of user profile
                 return do_shortcode( '[eo_events author='.$user_id.']' ); } 
    add_shortcode( 'eo_custom_shortcode', 'custom_shortcode' );
    

    the shortcode is not accepting the author artribute and is instead showing all upcoming events. Is author a valid attribute for the eo_events shortcode?

    Lukas Feddern
    #18976

    Yes it is, you may want to check that the $user_id is what you expect it to be.

    Stephen Harris
    #18977

    Yes I tried with a fixed user id and it worked, need to sort out get_author_meta() then.

    Thanks for your help

    Lukas Feddern
    #18982

    Ok got this to work, just one last question. I am trying to add an error message that displays when the shortcode returns no events:

    function custom_shortcode() {
    $user_id = bp_displayed_user_id();
    $events = do_shortcode( '[eo_events author='.$user_id.']' );
    
    if ( empty( $events ) ) {
        $events = "sorry no events yet";
    
    }
    
        return $events;
    }
    add_shortcode( 'eo_custom_shortcode', 'custom_shortcode' );
    

    The if statement is not working . So I assume that $event is not empty even when no events are returned. I tried doing !empty() and the message displays then so can only assume this is the case. Is there a event orgnaiser function to check if a variable contains any events. I looked through the codex but couldn’t find one.

    Thanks, I should be done with my continous barrage of questions when I get the site up and running.

    Lukas Feddern
    #18990

    do_shortcode() will return the HTML of the specified shortcode, and if event there are no events, there maybe some markup.

    The [eo_events] has a “no events” option (see: http://docs.wp-event-organiser.com/shortcodes/events-list), but you may find it easier to edit the event list template (event-organiser/templates/event-list-shortcodephp – move it to your theme first).

    Stephen Harris
Viewing 5 posts - 1 through 5 (of 5 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.