WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Form always gives true is email is correct. (8 posts)

  1. Patrick Hesselberg
    Member
    Posted 2 years ago #

    Hello.

    I've added my own fields in booking-fields.php, later validated in the hook em_booking_add. The code looks like:
    Booking-fields.php, The new field

    <p>
        <label for='city'>City *</label>
        <input type="text" name="city" id="city" class="input" <?php if(!empty($_REQUEST['city'])) echo "value='{$_REQUEST['city']}'"; ?> />
    </p>

    Functions.php, The hook

    global $EM_Notices;
    if( ! empty( $_REQUEST['city'] ) ){
        $EM_Booking->booking_meta['registration']['city'] = wp_kses( $_REQUEST['city'], array() );
    	} else {
        $registration = false;
        $EM_Notices->add_error( '<strong>ERROR</strong>: City.' );
    }

    If the email is failing, this error also comes up (if the field is empty), but nothing happends if the email is correct.

    Also doesnt give a "Succes" message.

    What's wrong?

    http://wordpress.org/extend/plugins/events-manager/

    [ Please do not bump, that's not permitted here. ]

  2. Patrick Hesselberg
    Member
    Posted 2 years ago #

    Is there any way to set $post_validation to false without writing code in plugin? This way im able to only allow my own validation.

  3. agelonwl
    Member
    Posted 2 years ago #

    Hi,

    can you provide a sample link to test?

  4. Patrick Hesselberg
    Member
    Posted 2 years ago #

  5. Patrick Hesselberg
    Member
    Posted 2 years ago #

    Do I have to use $post_validation to validation instead of
    $registration = false;
    $EM_Notices->add_error( 'ERROR' );

    How to I use $post_validation and how to I make my fields required?

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    Is there any way to set $post_validation to false without writing code in plugin? This way im able to only allow my own validation.

    yes, hook into the em_booking_validate or em_booking_get_post filters and change the argument from true to false (and add your errors).

  7. Patrick Hesselberg
    Member
    Posted 2 years ago #

    Sorry for bringing this up again, but im very close.

    Hooking into em_booking_validate:

    add_filter( 'em_booking_validate', 'dm_booking_validate' );
    function dm_booking_validate ( $result, $EM_Booking ) {

    My errors and succes works great. And it also registers the signup. Only problem is that I do not get my booking_meta with me.

    Im trying to do it like this:

    if( ! empty( $_REQUEST['city'] ) ) {
    	$EM_Booking->booking_meta['registration']['city'] = wp_kses( $_REQUEST['city'], array() );
    }

    Only thing im getting is the user_email.

    returning $result

    What im I doing wrong?

  8. Patrick Hesselberg
    Member
    Posted 1 year ago #

    The fix was to make EM_Booking global

    global $EM_Notices, $EM_Booking;

    Now saves all my metadata together with the booking

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic