It is a unusual error as a result of it wasn’t occurring earlier, it was really all working advantageous. I’ve eliminated all of the code I’ve added since I final examined it and it was working earlier than it broke.
I’ve a customized publish performing as a web page to submit a kind on and I’m processing the shape through a perform within the features.php web page in my plugin.
perform tm_add_new_job() {
if ( empty($_POST) || !wp_verify_nonce($_POST['tm_add_new_job'],'tm_add_new_job') ) {
wp_nonce_ays();
die();
} else {
$sort = $_POST['contacttype'];
swap ($sort) {
case 'e mail':
$title = $_POST['title'];
$title = $_POST['name'];
$surname = $_POST['surname'];
$e mail = $_POST['email'];
if (!empty($e mail)) {
// Publish new job and buyer
$new_customer_id = tm_add_customer($title, $title, $surname);
$new_job_id = tm_add_job($new_customer_id);
// Assign hyperlink to about_you web page
$about_you = get_page_by_path( 'about-you', '', 'jobs' );
$linked = get_post_permalink($about_you->ID);
$secret = get_post_meta( $new_customer_id, 'customer_secret', true );
$hyperlink = $linked .'?buyer='. $new_customer_id .'&secret='. $secret;
tm_mail_lead($e mail, $from, $customized, $hyperlink);
// Add job ID to buyer
add_metadata( 'publish', $new_customer_id, 'job_id', $new_job_id, false );
if (!empty($title)) {
// Add buyer title
add_metadata( 'publish', $new_customer_id, 'customer_title', $title, false );
}
if (!empty($title)) {
// Add buyer title
add_metadata( 'publish', $new_customer_id, 'customer_name', $title, false );
}
if (!empty($surname)) {
// Add buyer surname
add_metadata( 'publish', $new_customer_id, 'customer_surname', $surname, false );
}
// Add buyer e mail
add_post_meta( $new_customer_id, 'customer_email', $e mail, false );
} else {
// No e mail - Fail
wp_redirect( tm_new_job_link());
}
break;
case 'textual content':
$title = $_POST['sms_title'];
$title = $_POST['sms_name'];
$surname = $_POST['sms_surname'];
$cellular = $_POST['mobile'];
if (!empty($cellular)) {
// Publish new job and buyer
$new_customer_id = tm_add_customer($title, $title, $surname);
$new_job_id = tm_add_job($new_customer_id);
// Add job ID to buyer
add_metadata( 'publish', $new_customer_id, 'job_id', $new_job_id, false );
if (!empty($title)) {
// Add buyer title
add_metadata( 'publish', $new_customer_id, 'customer_title', $title, false );
}
if (!empty($title)) {
// Add buyer title
add_metadata( 'publish', $new_customer_id, 'customer_name', $title, false );
}
if (!empty($surname)) {
// Add buyer surname
add_metadata( 'publish', $new_customer_id, 'customer_surname', $surname, false );
}
// Add buyer e mail
add_metadata( 'publish', $new_customer_id, 'customer_mobile', $cellular, false );
} else {
// No Cellular Quantity - Fail
wp_redirect( tm_new_job_link());
}
break;
case 'buyer':
$picture = 'quoting.png';
break;
}
if ($_FILES) {
// Be sure that this file is included, as wp_generate_attachment_metadata() will depend on it.
require_once(ABSPATH . "wp-admin" . '/contains/picture.php');
require_once(ABSPATH . "wp-admin" . '/contains/file.php');
require_once(ABSPATH . "wp-admin" . '/contains/media.php');
$file = $_FILES[featured_image];
$file_return = wp_handle_upload( $file, array('motion' => 'tm_add_new_job' ) );
if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
return false;
} else {
$filename = $file_return['file'];
$attachment = array(
'post_mime_type' => $file_return['type'],
'post_title' => preg_replace( '/.[^.]+$/', '', basename( $filename ) ),
'post_content' => '',
'post_status' => 'inherit',
'guid' => $file_return['url']
);
$attachment_id = wp_insert_attachment( $attachment, $file_return['url'] );
// Generate the metadata for the attachment, and replace the database document.
$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
wp_update_attachment_metadata( $attachment_id, $attachment_data );
set_post_thumbnail( $new_job_id, $attachment_id );
}
}
// success go to new job publish.
wp_redirect( get_permalink($new_job_id));
}
}
add_action( 'admin_post_tm_add_new_job', 'tm_add_new_job' );
FYI: The shape works and the information is inserted into the database, the one drawback is it’s caught on a clean (white display) admin-post.php web page. What am I doing unsuitable right here?
UPDATE:
I’ve found that it redirects provided that I add a picture?