Home › Forums › Backend Issues (wp-admin) › Update Checkbox Field with Multiple Values using MySQL Queries › Reply To: Update Checkbox Field with Multiple Values using MySQL Queries
None that I can see! The form seems to submit, the page redirects, but the field value is null:
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post" ) {
// Do some minor form validation to make sure there is content
if (isset ($_POST['title'])) {
$title = $_POST['title'];
} else {
echo 'Please enter a title';
}
if (isset ($_POST['description'])) {
$description = $_POST['description'];
} else {
echo 'Please enter the content';
}
$trendline_20 = serialize(array($_POST['trendline_20-m5bull'], $_POST['trendline_20-m5bear'], $_POST['trendline_20-m15bull'], $_POST['trendline_20-m15bear'], $_POST['trendline_20-m30bull'], $_POST['trendline_20-m30bear'], $_POST['trendline_20-h1bull'], $_POST['trendline_20-h1bear'], $_POST['trendline_20-h2bull'], $_POST['trendline_20-h2bear'], $_POST['trendline_20-h4bull'], $_POST['trendline_20-h4bear'], $_POST['trendline_20-d1bull'], $_POST['trendline_20-d1bear']));
$option_liquidity = $_POST['option_liquidity'];
$option_liquidity_min = $_POST['option_liquidity_min'];
$option_liquidity_max = $_POST['option_liquidity_max'];
// Add the content of the form to $post as an array
$new_post = array(
'post_title' => $title,
'post_content' => $description,
'post_status' => 'draft', // Choose: publish, preview, future, draft, etc.
'post_type' => 'custom_scan' //'post',page' or use a custom post type if you want to
);
//save the new post
$post_id = wp_insert_post($new_post);
global $wpdb;
$wpdb->query(
"INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
VALUES ($post_id, 'trendline_20', $trendline20),($post_id, '_trendline_20', 'field_634819cc60fd8')"
);
//redirect
wp_redirect(get_permalink($post_id)); exit;
} ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.