Appointment confirmation editing

When I use the short code [app_confirmation] I would like to edit some fields that are automatically populated, mostly service provider and lasts fields. I can use CSS to hide these classes, but would like a more elegant way of removing those.

  • Vinod Dalvi

    Hi @Albert,

    Welcome to the WPMU Dev community and thank you for your question.

    You can remove these fields by adding the following code in the functions.php file of your child theme.

    function custom_app_additional_fields( $rect_data ){
    	global $appointments;
    
    		// Get user form data from his cookie
    		if ( isset( $_COOKIE["wpmudev_appointments_userdata"] ) )
    			$data = unserialize( stripslashes( $_COOKIE["wpmudev_appointments_userdata"] ) );
    		else
    			$data = array();
    
    		$n = isset( $data["n"] ) ? sanitize_text_field( $data["n"] ) : ''; // Name
    		$e = isset( $data["e"] ) ? sanitize_text_field( $data["e"] ) : ''; // Email
    		$p = isset( $data["p"] ) ? sanitize_text_field( $data["p"] ) : ''; // Phone
    		$a = isset( $data["a"] ) ? sanitize_text_field( $data["a"] ) : ''; // Address
    		$c = isset( $data["c"] ) ? sanitize_text_field( $data["c"] ) : ''; // City
    		$g = isset( $data["g"] ) ? sanitize_text_field( $data["g"] ) : ''; // GCal selection
    		if ( $g )
    			$gcal_checked = ' checked="checked"';
    		else
    			$gcal_checked = '';
    
    		// User may have already saved his data before
    		if ( is_user_logged_in() ) {
    			global $current_user;
    			$user_info = get_userdata( $current_user->ID );
    
    			$name_meta = get_user_meta( $current_user->ID, 'app_name', true );
    			if ( $name_meta )
    				$n = $name_meta;
    			else if ( $user_info->display_name )
    				$n = $user_info->display_name;
    			else if ( $user_info->user_nicename )
    				$n = $user_info->user_nicename;
    			else if ( $user_info->user_login )
    				$n = $user_info->user_login;
    
    			$email_meta = get_user_meta( $current_user->ID, 'app_email', true );
    			if ( $email_meta )
    				$e = $email_meta;
    			else if ( $user_info->user_email )
    				$e = $user_info->user_email;
    
    			$phone_meta = get_user_meta( $current_user->ID, 'app_phone', true );
    			if ( $phone_meta )
    				$p = $phone_meta;
    
    			$address_meta = get_user_meta( $current_user->ID, 'app_address', true );
    			if ( $address_meta )
    				$a = $address_meta;
    
    			$city_meta = get_user_meta( $current_user->ID, 'app_city', true );
    			if ( $city_meta )
    				$c = $city_meta;
    		}
    
    		$ret = '';
    		$ret .= '<div class="appointments-confirmation-wrapper"><fieldset>';
    		$ret .= '<legend>';
    		$ret .= $title;
    		$ret .= '</legend>';
    		$ret .= '<div class="appointments-confirmation-service">';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-confirmation-start">';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-confirmation-price" style="display:none">';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-name-field2" style="display:none">';
    		$ret .= '<label><span>'. $name . '</span><input type="text" class="appointments-name-field-entry" id="' . esc_attr(apply_filters('app-shortcode-confirmation-name_field_id', 'appointments-field-customer_name')) . '" value="'.$n.'" /></label>';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-email-field" style="display:none">';
    		$ret .= '<label><span>'. $email . '</span><input type="text" class="appointments-email-field-entry" id="' . esc_attr(apply_filters('app-shortcode-confirmation-email_field_id', 'appointments-field-customer_email')) . '" value="'.$e.'" /></label>';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-phone-field" style="display:none">';
    		$ret .= '<label><span>'. $phone . '</span><input type="text" class="appointments-phone-field-entry" id="' . esc_attr(apply_filters('app-shortcode-confirmation-phone_field_id', 'appointments-field-customer_phone')) . '" value="'.$p.'" /></label>';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-address-field" style="display:none">';
    		$ret .= '<label><span>'. $address . '</span><input type="text" class="appointments-address-field-entry" id="' . esc_attr(apply_filters('app-shortcode-confirmation-address_field_id', 'appointments-field-customer_address')) . '" value="'.$a.'" /></label>';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-city-field" style="display:none">';
    		$ret .= '<label><span>'. $city . '</span><input type="text" class="appointments-city-field-entry" id="' . esc_attr(apply_filters('app-shortcode-confirmation-city_field_id', 'appointments-field-customer_city')) . '" value="'.$c.'" /></label>';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-note-field" style="display:none">';
    		$ret .= '<label><span>'. $note . '</span><input type="text" class="appointments-note-field-entry" id="' . esc_attr(apply_filters('app-shortcode-confirmation-note_field_id', 'appointments-field-customer_note')) . '" /></label>';
    		$ret .= '</div>';
    		$ret .= '<div class="appointments-gcal-field" style="display:none">';
    		$ret .= '<label><span>'.$appointments->gcal_image.'</span><input type="checkbox" class="appointments-gcal-field-entry" id="' . esc_attr(apply_filters('app-shortcode-confirmation-gcal_field_id', 'appointments-field-customer_gcal')) . '" '.$gcal_checked.' />&nbsp;';
    		$ret .= $gcal;
    		$ret .= '</label></div>';
    
    		return $ret;
    }
    add_filter( 'app_additional_fields', 'custom_app_additional_fields');

    Best Regards,
    Vinod Dalvi

  • Jack Kitterhing

    Hi there @Albert,

    Hope you're well today and sorry about the delay on this.

    I've just done some testing here and Vinod's code seemed to work correctly for me on my install, could you provide me with the following to check this on your install, so we can get this resolved ASAP. :slight_smile:

    - In the subject field add "Attn: Jack Kitterhing"
    - Link back to this thread
    - Include admin/network access
    - Include FTP
    - Include any relevant URLS for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    https://premium.wpmudev.org/contact/

    Thanks!

    Kind Regards
    Jack.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.