Making booking form display to non-logged in users

WordPress Event Management, Calendars & Registration Forums General Question Making booking form display to non-logged in users

This topic contains 8 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 1 month ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #21242

    Hi Stephen,

    Kindly help with this problem. Here is my scenario:

    I have chosen to let only logged in users purchase tickets. But choosing this setting automatically hides the booking form from logged out users. But I want to display the booking form at all times so that even logged out users can see the price and select a quantity. After selecting quantity and clicking button, they can then login and continue with the purchase. In other words, even though only logged-in users can purchase, I want to still display the booking form to logged out users. I looked at the eo-booking-form and tried to comment some things out. This didn’t work.

    Bond Nwonye
    #21252

    Hi Bond,

    There’s an option in Settings > Event Organiser > Bookings to allow logged-out users to place a booking, but require that they have an account created as part of the process.

    Stephen Harris
    #21256

    Hi Stephen,

    Thanks for your response. I don’t think I explained myself well, hence your answer was not what I need. I know the option you offered but that’s not what I want to select. Rather, I want to select the “No” option. Selecting this is currently coded to hide the booking form from logged out users. But I want to negate this hiding and, instead, show the booking form to logged out users even when I selected “No” as the setting for “Allowing logged out users to place a booking”.

    Bond Nwonye
    #21262

    Ok, so you want to show the booking form to logged-out users, even though they cannot place a booking?

    The logic for whether or not to display the booking form to logged-out users is contained in event-organiser-pro/templates/eo-booking-form.php. You can copy that to your theme and edit it as desired.

    Stephen Harris
    #21269

    Actually, I copied that file to my child theme folder and attempted the Edit by commenting out some of the conditional if/else lines. But these did not display the form. Also, even though I want to display the form, I still want to have the user login before he can purchase. There is also the risk that my editing could take away this login requirement. Any snippet of code or function would be appreciated.

    Bond Nwonye
    #21270

    You just need to remove/comment out the following:

    //If logged out and guess cannot book
    }elseif( !is_user_logged_in() && !eventorganiser_pro_get_option( 'allow_guest_booking' ) ){
    
        //User is logged out, guests cannot book. Show login form and don't display booking form
        echo apply_filters( 'eventorganiser_booking_login_required', '<p>'.__( 'Only logged in users can place bookings', 'eventorganiserp' ).'</p>' );
        eo_login_form( array( 'form_id' => 'eo-booking-login-form-login-required', 'label_username' => __( 'Username / Email', 'eventorganiserp' ) )  );
    

    It won’t allow users to actually make a booking: they’ll be returned to the form with an error message.

    Stephen Harris
    #21285

    Thanks Stephen. This helped out but did not quite get me to what I was looking for. After I commented the lines of code out, the booking form displayed to non-logged in users, which is good. But the registration form fields (first name, last name and email) also continued to display, which is not desired. My aim is to simply show the booking form so that the visitor can see the price and when he clicks the button (after selecting ticket quantity), I can do one of two things, depending on which is easier for me:

    1. Redirect him to a login page at mysite.com/sign_in. In redirecting him, I will need to pass the page info to his login so that he can still see his selection once he logs in. An example of this can be seen here:

    https://generalassemb.ly/education/picture-this-instagram-for-business/chicago/19457

    If you click the ATTEND button, notice how it redirects you to a login page.

    1. I am using a membership plugin that enables me to embed login fields within a template. I can embed these on the same page so that when I click the button after making a selection, it will simply unhide the fields (instead of unhiding the event-organizer login fields). This way, the user can login and still see his selection because this membership plugin has a setting that enables the user to retain the last viewed page after he logs in.

    So in essence, I want to display the booking form without displaying the registration fields which seems to be the default situation.

    Bond Nwonye
    #21333

    Hello Stephen,
    I still need help with completely hiding the registration form that comes with the booking form. Although I have spent many hours scouring through the files, I was able to hide only the first name and last name fields (by copyng eo-booking-form-name.php to my child time and deleting all its content), but the email field (with the placeholder “john@example.com”) still persists and is not removed. I have searched different files and done trial and error by commenting out things. But none of that worked. I had to un-comment them again. .

    Kindly help with showing me the file and section how to successfully the registration form. Like mentioned, I have removed the fields/labels for First Name and Last Name, but apparently the email is coded in a different way.

    Bond Nwonye
    #21334

    Hi Bond,

    I’m afraid you’re trying to do is not straightforward. From what it sounds like, you want to allow the user to fill in the booking form and then, if they are not logged-in, provide a log-in/sign-up interface to complete the booking.

    The plug-in however, embeds the log-in/sign-up part into the booking form. Although you can opt to allow logged-in users to place bookings (or not) or allow logged-out users to sign up when making a booking (or not, or even require it) – the sign up / log-in parts, if present, are part of the booking form.

    To implement what you’re suggesting is possible. However, it would require development effort. To summarise, you would need to do the following:

    1. Configure the plug-in to not allow logged-out users to make bookings, but edit the booking form template to display the form anyway.
    2. Intercept a booking by a logged-out user
    3. Store that data (as session data presumably) to retrieve later and redirect them to your membership log-in page
    4. Once sign-up, redirect them back to the booking form, with the data pre-filled.

    For (2) you can use the action eventorganiser_validate_booking_form_submission which passes a EO_Booking_Form instance – complete with the data from the form. This contains a collection of EO_Booking_Form_Element instances which you can iterate through to the value of. (EO_Booking_Form_Element::get_value()). is_user_logged_in() will tell you if the user is logged-in.

    For (3) you should then store that data in a suitable format (possibly has a large array stored as session data).

    For (4) you can pre-populate the field with the action eventorganiser_get_event_booking_form which passes a EO_Booking_Form instance – which you should populate with data from (2). ( i.e. using EO_Booking_Form_Element::set_value())

    In response to your last message, the template for the email field is eo-booking-form-input.php – but I wouldn’t recommend editing the element templates to try and achieve what you’re doing.

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