WordPress.org

Support

Support » Plugins and Hacks » Events Manager » [Resolved] [Plugin: Events Manager] em_booking_validate doesnt save my booking_meta

[Resolved] [Plugin: Events Manager] em_booking_validate doesnt save my booking_meta

  • 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?
    How can I save my custom booking meta?

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marcus

    @netweblogic

    you probably want to hook into em_booking_get_post

    em_booking_validate hook works. The fix was to make $EM_Booking a global:

    Full code:

    // Validate and insert custom metadata
    add_filter( 'em_booking_validate', 'dm_booking_validate' );
    function dm_booking_validate ( $result, $EM_Booking ) {
    	global $EM_Notices, $EM_Booking;
    
    	if( empty($EM_Booking->booking_meta['registration']) ) $EM_Booking->booking_meta['registration'] = array();
    
    	if( ! empty( $_REQUEST['title'] ) ) {
    		$EM_Booking->booking_meta['registration']['title'] = wp_kses( $_REQUEST['title'], array() );
    		$EM_Booking->title = wp_kses( $_REQUEST['title'], array() );
    	}
    	if( ! empty( $_REQUEST['name'] ) ) {
    		$EM_Booking->booking_meta['registration']['name'] = wp_kses( $_REQUEST['name'], array() );
    	} else {
    		$result = false;
    		$EM_Notices->add_error( '<strong>Fejl</strong>: Indtast venligst dit Navn.' );
    	}
    	if ( $_REQUEST['user_email'] && !is_email( $_REQUEST['user_email'] ) ) {
    		$result = false;
    		$EM_Notices->add_error( __( '<strong>Fejl</strong>: E-mailadressen er ikke korrekt.', 'dbem') );
    	} elseif ( is_email( $_REQUEST['user_email'] ) ) {
    		$EM_Booking->booking_meta['registration']['user_email'] = wp_kses( $_REQUEST['user_email'], array() );
    	} else {
    		$result = false;
    		$EM_Notices->add_error(__( '<strong>Fejl</strong>: Indtast venligst din E-mailadresse.', 'dbem') );
    	}
    	if( ! empty( $_REQUEST['company'] ) ) {
    		$EM_Booking->booking_meta['registration']['company'] = wp_kses( $_REQUEST['company'], array() );
    	} else {
    		$result = false;
    		$EM_Notices->add_error( '<strong>Fejl</strong>: Indtast venligst din Virksomhed.' );
    	}
    	if( ! empty( $_REQUEST['billingaddress'] ) ) {
    		$EM_Booking->booking_meta['registration']['billingaddress'] = wp_kses( $_REQUEST['billingaddress'], array() );
    	}
    	if( ! empty( $_REQUEST['zip'] ) ) {
    		$EM_Booking->booking_meta['registration']['zip'] = wp_kses( $_REQUEST['zip'], array() );
    	}
    	if( ! empty( $_REQUEST['city'] ) ) {
    		$EM_Booking->booking_meta['registration']['city'] = wp_kses( $_REQUEST['city'], array() );
    	}
    	if( ! empty( $_REQUEST['tlf'] ) ) {
    		$EM_Booking->booking_meta['registration']['tlf'] = wp_kses( $_REQUEST['tlf'], array() );
    	}
    	if( ! empty( $_REQUEST['ean'] ) ) {
    		$EM_Booking->booking_meta['registration']['ean'] = wp_kses( $_REQUEST['ean'], array() );
    	}
    	return $result;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: Events Manager] em_booking_validate doesnt save my booking_meta’ is closed to new replies.
Skip to toolbar