Displaying Events created by a user

This topic contains 7 replies, has 2 voices, and was last updated by  Stephen Harris 8 years, 7 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #18760

    Is it possible to display the events created by a user using the events list shorcode? I would like to display on someones buddypress profile the events they have created for others to view.

    Thanks

    Lukas Feddern
    #18761

    like would it be possible to do something like this

    add something like this to functions.php:

    function custom_shortcode() {

    $user_id = get_the_author_meta( 'ID' );
    echo get_events_created_by_user( $user_id );
    

    }
    add_shortcode( ‘eo_custom_shortcode’, ‘custom_shortcode’ );

    then use [ep_custom_shortcode] on the buddypress profile?

    but is there a function like get_events_created_by_user() for event organiser.

    BTW i have very limited knowledge of php at the moment – just learning… Any help would really be appreciated as EO does everything I need apart from this!

    Lukas Feddern
    #18762

    If this isn’t possible would it be possbile to achieve a similar result by doing an automatic search by the user name (the main page title on account name) and then displaying the results?

    Lukas Feddern
    #18771

    Hi Lukas,

    If you wanted a list of events owned by a user, you could use:

    [eo_events author=<id of user>]
    

    So you could create a custom shortcode which invokes that one, and sets the ID. Or you could use eo_get_events(), with 'author'=>$user_id (see codex for examples of this function: codex.wp-event-organiser.com/function-eo_get_events.html ). I’m assuming here that $user_id is the ID of the desired user.

    If you wanted events submitted by a user then you would need to use eo_get_events() to get an array of events, and then generate your own HTML output:

    $events = eo_get_events( array(
         'meta_query' => array(
              array(
                    'key' => '_eventorganiser_fes_user',
                    'value' => $user_id,
              ),
         ),
    

    ) );

    Again, assuming $user_id is the ID of the desired user.

    Stephen Harris
    #18776

    Hey Stephen,

    Thanks for your reply, just a couple of questions. Surely an event submitted by a user would be owned by a user?
    What is the difference?

    Also if I want to use the second method could I be annoying and ask for a little bit more guidance. What would I need to include in the functions.php file and what would I need to include in the relevant template to display a table of submitted events?

    thanks

    Lukas Feddern
    #18777

    So assuming that a user “owns” on event by submitting them.
    Would a way of creating a custom shortcode that could be used in the
    template for buddypress profile of the user who submitted the event (using do_shortcode()) be:

    function custom_shortcode(){

    ‘author’=> $user_id;
    eo_get_events($user_id)
    }
    add_shortcode( ‘eo_custom_shortcode’, ‘custom_shortcode’ );

    or would I have to use $user_id = get_the_author_meta( ‘ID’ ); to get the ID of the creator of the
    buddypress profile. Or have I got this wrong completely!!

    Any help appreciated, thanks.

    Lukas Feddern
    #18778

    Or would it be:

    function custom_shortcode()
    {
    $user_id = get_the_author_meta (‘ID’)

    do_shortcode(‘[eo_events author=<$user_id>]’)
    }

    add_shortcode( ‘eo_custom_shortcode’, ‘custom_shortcode’ );

    *to be clear I want to display the events being organised by the buddypress user (these will be submitted by the user using forms)

    Lukas Feddern
    #18798

    To clarify the owner or organiser of the event is not necessarily the person who submits it (though typically is). Indeed the plug-in settings allow you to assign submitted events to a particular user (if not the submitter), or at any time you can edit the organiser of an event.

    So the following would work:

    function custom_shortcode(){
         $user_id = get_the_author_meta( 'ID' );
         do_shortcode( '[eo_events author='.$user_id.']' );
    }
    add_shortcode( 'eo_custom_shortcode', 'custom_shortcode' );
    

    I’m assuming here that

    $user_id = get_the_author_meta( 'ID' );
    

    retrieves the ID of the user whose profile is being rendered. I don’t know this, and you would have to check with the BuddyPress developers.

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