Insert webservice with post type with metabox value in wordpress
Insert webservice with post type with metabox value in wordpress, wordpress, wordpress webserivce, insert webserice in wordpress,
<?php
require_once '../wp-load.php';
require_once '../wp-config.php';
header('Content-type: application/json');
$response = array();
$alu_name= sanitize_meta('name_alu_c1',$_POST['metal_name'],'user');
$alu_email= sanitize_email($_POST['metal_email']);
$alu_mobile= sanitize_meta('phone_alu_c1',$_POST['metal_mobile'],'user');
$alu_city= sanitize_meta('city_alu_c1',$_POST['metal_city'],'user');
$alu_message= sanitize_meta('message_alu_c1',$_POST['metal_message'],'user');
$my_cptpost_args = array(
'post_title' => $alu_name,
'post_status' => 'publish',
'post_type' => "enter-your-post-type-name",
);
$admin_email = "admin@gmail.com";
$headers[] = 'From: <test@gmail.com>';
$second_email = "test@gmail.com";
$cpt_id = wp_insert_post($my_cptpost_args, $wp_error );
if($cpt_id){
$response['message'] = 'Thank you! We will get back to you soon.';
$response['status'] = 1;
add_post_meta($cpt_id, 'name_alu_c1', $alu_name, true);//here insert two custom field data.
add_post_meta($cpt_id, 'email_address_alu_c1', $alu_email, true);//here insert two custom field data.
add_post_meta($cpt_id, 'phone_alu_c1', $alu_mobile, true);//here insert two custom field data.
add_post_meta($cpt_id, 'city_alu_c1', $alu_city, true); //here insert two custom field data..
add_post_meta($cpt_id, 'message_alu_c1', $alu_message, true); //here insert two custom field data..
$email_temp = "Name : ".$alu_name."<br/>";
$email_temp .= "Email : ".$alu_email."<br/>";
$email_temp .= "Phone : ".$alu_mobile."<br/>";
$email_temp .= "City : ".$alu_city."<br/>";
$email_temp .= "Message : ".$alu_message."<br/>";
$inqury = " Inquiry for ".$alu_name;
$test = wp_mail( $alu_email, "Contact Us", "Thank you! We will get back to you soon.",$headers);
$test = wp_mail($admin_email, $inqury, $email_temp );
if($second_email !=''){
$test = wp_mail($second_email, $inqury, $email_temp );
}
}else{
$response['message'] = 'Some Error';
$response['status'] = 2;
}
echo json_encode($response);
?>
require_once '../wp-load.php';
require_once '../wp-config.php';
header('Content-type: application/json');
$response = array();
$alu_name= sanitize_meta('name_alu_c1',$_POST['metal_name'],'user');
$alu_email= sanitize_email($_POST['metal_email']);
$alu_mobile= sanitize_meta('phone_alu_c1',$_POST['metal_mobile'],'user');
$alu_city= sanitize_meta('city_alu_c1',$_POST['metal_city'],'user');
$alu_message= sanitize_meta('message_alu_c1',$_POST['metal_message'],'user');
$my_cptpost_args = array(
'post_title' => $alu_name,
'post_status' => 'publish',
'post_type' => "enter-your-post-type-name",
);
$admin_email = "admin@gmail.com";
$headers[] = 'From: <test@gmail.com>';
$second_email = "test@gmail.com";
$cpt_id = wp_insert_post($my_cptpost_args, $wp_error );
if($cpt_id){
$response['message'] = 'Thank you! We will get back to you soon.';
$response['status'] = 1;
add_post_meta($cpt_id, 'name_alu_c1', $alu_name, true);//here insert two custom field data.
add_post_meta($cpt_id, 'email_address_alu_c1', $alu_email, true);//here insert two custom field data.
add_post_meta($cpt_id, 'phone_alu_c1', $alu_mobile, true);//here insert two custom field data.
add_post_meta($cpt_id, 'city_alu_c1', $alu_city, true); //here insert two custom field data..
add_post_meta($cpt_id, 'message_alu_c1', $alu_message, true); //here insert two custom field data..
$email_temp = "Name : ".$alu_name."<br/>";
$email_temp .= "Email : ".$alu_email."<br/>";
$email_temp .= "Phone : ".$alu_mobile."<br/>";
$email_temp .= "City : ".$alu_city."<br/>";
$email_temp .= "Message : ".$alu_message."<br/>";
$inqury = " Inquiry for ".$alu_name;
$test = wp_mail( $alu_email, "Contact Us", "Thank you! We will get back to you soon.",$headers);
$test = wp_mail($admin_email, $inqury, $email_temp );
if($second_email !=''){
$test = wp_mail($second_email, $inqury, $email_temp );
}
}else{
$response['message'] = 'Some Error';
$response['status'] = 2;
}
echo json_encode($response);
?>
No comments:
Post a Comment
Thank You For Comment