/*
Theme Name: UltraViolette Child
Theme URI: https://ultraviolette.elated-themes.com
Template: ultraviolette
Author: Elated Themes
Author URI: http://themeforest.net/user/elated-themes
Description: Design Portfolio Theme
Tags: one-column,two-columns,three-columns,four-columns,left-sidebar,right-sidebar,custom-menu,featured-images,flexible-header,post-formats,sticky-post,threaded-comments,translation-ready
Version: 1.0.1672480435
Updated: 2022-12-31 09:53:55

*/


// Add the custom columns to the book post type:
add_filter( 'inquiry_list_posts_columns', 'set_custom_edit_book_columns' );
function set_custom_edit_book_columns($columns) {
    unset( $columns['author'] );
    $columns['inquiry_status'] = __( 'Inquiry Status', 'your_text_domain' );
    $columns['inquiry_source'] = __( 'Inquiry Source', 'your_text_domain' );
    $columns['parent_name'] = __( 'Parent Name', 'your_text_domain' );
    $columns['child_name'] = __( 'Child Name', 'your_text_domain' );
    $columns['d_o_b'] = __( 'DOB(MM/DD/YYYY)', 'your_text_domain' );
    $columns['start_date'] = __( 'Start Date', 'your_text_domain' );
    $columns['program'] = __( 'Program', 'your_text_domain' );
    $columns['email'] = __( 'Email', 'your_text_domain' );
    $columns['phone'] = __( 'Phone', 'your_text_domain' );

    return $columns;
}

// Add the data to the custom columns for the book post type:
add_action( 'manage_inquiry_list_posts_custom_column' , 'custom_book_column', 10, 2 );
function custom_book_column( $column, $post_id ) {
    switch ( $column ) {

        case 'inquiry_source' :
            $terms = get_the_term_list( $post_id , 'book_author' , '' , ',' , '' );
            if ( is_string( $terms ) )
                echo $terms;
            else
                _e( 'Unable to get author(s)', 'your_text_domain' );
            break;

        case 'inquiry_status' :
			$value = get_field( "inquiry_stayus", $post_id );
            echo $value; 
            break;
		case 'parent_name' :
			$value = get_field( "inquiry_stayus", $post_id );
            echo $value; 
            break;
		case 'child_name' :
			$value = get_field( "child_first_name", $post_id );
            echo $value; 
            break;
		case 'd_o_b' :
			$value = get_field( "date_of_birth", $post_id );
            echo $value; 
            break;
		case 'start_date' :
			$value = get_field( "start_date", $post_id );
            echo $value; 
            break;
		case 'program' :
			$value = get_field( "programe", $post_id );
            echo $value; 
            break;
		case 'email' :
			$value = get_field( "email_", $post_id );
            echo $value; 
            break;
		case 'phone' :
			$value = get_field( "phone_", $post_id );
            echo $value; 
            break;

    }
}

add_action( 'wpcf7_before_send_mail', 'wpcf7_add_text_to_mail_body' );

function wpcf7_add_text_to_mail_body($contact_form){
	$form_id = $contact_form->posted_data['_wpcf7'];
	//if ($form_id == 13){ 
		 $title = $_POST['radio-658'];
		 $my_post = array(
						'post_title'    => $_POST['FirstName'],
						'post_content'  => $_POST['textarea-98'],
						'post_status'   => 'publish',
						'post_author'   => 1,
						'post_type'     => 'inquiry_list',
					);
		$post_id = wp_insert_post( $my_post );
		update_post_meta( $post_id, 'first_name', $_POST['FirstName'] );
		update_post_meta( $post_id, 'last_name', $_POST['LastName'] );
		update_post_meta( $post_id, 'phone_', $_POST['phone'] );
		update_post_meta( $post_id, 'email_', $_POST['Email'] );
        update_post_meta( $post_id, 'which_programe_you_are_intrested', $_POST['radio-658'] );
		
	//}
	 
	return $contact_form;

}

