• Resolved Ajalon

    (@ajalon)


    I am using Events Manager and have found it to be great for my application.
    On the Events list page I would like to show a simple Yes or Yes/No against those events which the logged on user is attending. Is there a way of doing this by using a placeholder to identify the bookings against an event? I have added the extra column required and used {has_bookings} but it either shows all Yes or nothing.
    Any advice greatly appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    just to confirm, what you’ve wanted to do is use a conditional placeholder to check whether an event does have attendees/bookings or not?

    Thread Starter Ajalon

    (@ajalon)

    Hi Angelo

    I want to confirm that the currently logged on user has a booking for an event and indicate this alongside the event in the event list. e.g.
    Date Event/location Attending

    I have attempted to adapt the code from the tutorials as follows, but when I add it to the functions.php file the website locks up. I am obviously doing something stupid!

    add_filter(’em_event_output_placeholder’,’my_em_isbooked_placeholders’,1,3);
    function my_em_isbooked_placeholders($user_id = false, $replace, $EM_Event, $result){
    ????global $wp_query, $wp_rewrite;
    ????switch( $result ){
    ????????case ‘#_ISBOOKED’:
    ????????$replace = ‘No’;
    /**
    * Checks to see if user has a booking for this event
    * @param unknown_type $user_id
    */
    if( $user_id === false ){
    $user_id = get_current_user_id();
    }
    if( is_numeric($user_id) && $user_id > 0 ){
    foreach ($this->bookings as $EM_Booking){
    if( $EM_Booking->person->ID == $user_id && !in_array($EM_Booking->booking_status, array(2,3)) ){
    replace ‘Yes’;
    }else{
    replace = ‘No’;
    }
    }
    }
    }
    ????return $replace;
    }

    Do you have the code correctly wrapped within PHP tags?

    Thread Starter Ajalon

    (@ajalon)

    Yes, I am putting it at the end of the theme’s functions.php file before the ?> tag.

    Can you post a link where we can see the functions.php file?

    Thread Starter Ajalon

    (@ajalon)

    A text version of the Functions.php can be viewed here: https://ww2ops.uk/functions.txt (the php file required login to view). I have made some modifications to try to just get a simple “Yes” if the user has a booking and nothing otherwise. The new code is at the very end of the file.
    Many thanks.

    I think the problem is the wrong kind of single quote character in the custom code snippet. In a couple of places you have curly / smart quotes instead of the straight kind.

    Try changing

    $replace = ‘Yes’;

    to

    $replace = 'Yes;

    and

    add_filter(’em_event_output_placeholder’,’my_em_styles_placeholders’,1,3);

    to

    add_filter('em_event_output_placeholder','my_em_styles_placeholders',1,3);

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Show User has bookings on Events List’ is closed to new replies.