Hello world!
March 11, 2017
Want create site? Find Free WordPress Themes and plugins.

function my_wpcf7_save($cfdata) {
$formtitle = $cfdata->title;
global $wpdb;
$form_to_DB = WPCF7_Submission::get_instance();
if ( $form_to_DB ) {
$formData = $form_to_DB->get_posted_data();
$uploaded_files = $form_to_DB->uploaded_files(); // this allows you access to the upload file in the temp location
}
if ( $formtitle == ‘sync_test’) {
// create a new post
$newpost = array(
‘post_type’ => ‘students’,
‘post_title’ => $formData[‘your-firstname’]. ‘ ‘ .$formData[‘your-lastname’]. ‘ – ‘ .$formData[‘your-company’],
‘post_status’ => ‘pending’);
$newpostid = wp_insert_post($newpost);
// add meta data for the new post
add_post_meta($newpostid, ‘rli_meta_students_first_name’, $formData[‘your-firstname’]);
add_post_meta($newpostid, ‘rli_meta_students_surname’, $formData[‘your-lastname’]);
add_post_meta($newpostid, ‘rli_meta_students_email’, $formData[‘your-email’]);

add_post_meta($newpostid, ‘rli_meta_students_notes’, $formData[‘your-notes’]);
//add_post_meta($newpostid, ‘rli_meta_students_photo’, $formData[‘ProfilePhoto’]); — do this after saving image in uploads
$image_name = $formData[‘ProfilePhoto’];
$image_location = $uploaded_files[“ProfilePhoto”];
$image_content = file_get_contents($image_location);
if ($image_content==false){
$check = ‘content fail’;
} else {
$check = ‘content success’;
}
$wud = wp_upload_dir();
$upload = wp_upload_bits( $image_name, null, $image_content);
$chemin_final = $upload[‘url’]; // http://www.xxxx.com/wp-content/uploads/2015/09/xxxx.jpg
$filename= $upload[‘file’]; // /home/sites/xxxx.com/public_html/wp-content/uploads/wpcf7_uploads/1565907367/xxxx.jpg
if ($filename>”) {
require_once(ABSPATH . ‘wp-admin/includes/admin.php’);
$wp_filetype = wp_check_filetype(basename($filename), null );
$attachment = array(
‘post_mime_type’ => $wp_filetype[‘type’],
‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename($filename)),
‘post_content’ => ”,
‘post_status’ => ‘inherit’
);
$attach_id = wp_insert_attachment( $attachment, $filename, $newpostid);
require_once(ABSPATH . ‘wp-admin/includes/image.php’);
$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
wp_update_attachment_metadata( $attach_id, $attach_data );
update_post_meta($newpostid, “_thumbnail_id”, $attach_id);
add_post_meta($newpostid, ‘rli_meta_students_photo’, $chemin_final); // $formData[‘ProfilePhoto’]
}
}
}
add_action(‘wpcf7_before_send_mail’, ‘my_wpcf7_save’,1);

Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

Your email address will not be published. Required fields are marked *