INCOMING: Parede do código para o formulário e $ _POST, não atualizando o valor do campo personalizado

tem sido um longo período de dois dias em uma tentativa de programa um plugin do zero para fornecer uma página de destino de frente com 2 formas.

Dependendo do formulário que o usuário deseja usar, o formulário deve alterar um valor no database (adicionar ou criar se o campo personalizado inexistente “chave” => “valor”).

Sem sorte, muitas mudanças foram feitas para os formulários e as funções associadas a manipular $ _POST e obter seu valor etc e sem sucesso!

Alguém está disposto a dar uma olhada no meu código abaixo? O objective é diferenciar entre duas formas no momento da submissão. Depois disso, se o segundo botão de envio for pressionado, um valor de campo personalizado será atualizado na tabela wp_postmeta.

ID); // salt shaker, drawing straws, randomness function lucs_random_thumbnail() { $lucs_random_image = rand(0,1); if ($lucs_random_image == 0) { $lucs_thumb_ra = plugins_url('/img/thumb0.png',__FILE__); } else { $lucs_thumb_ra = plugins_url('/img/thumb1.png',__FILE__); } return $lucs_thumb_ra; } // if participant has no featured image, display the following default image included in plugin function lucs_get_featured_image() { if (has_post_thumbnail()) { the_post_thumbnail('thumbnail',array( 'class' => 'showcase-thumbnail' )); } else { echo 'Organization'; } } /*START OF CONTESTANT FORM*/ if (isset($_POST['lucs_nonce_guest']) && wp_verify_nonce($_POST['lucs_nonce_guest'],'post_nonce')) { if (isset($_POST['password']) && trim($_POST['password']) != '') { $lucs_form_details = array( 'post_title' => wp_strip_all_tags($_POST['org_contestant']), 'post_content' => sanitize_text_field($_POST['org_reason']), 'post_type' => 'lucs_contestant', 'post_status' => 'trash', 'comment_status' => 'closed', ); $lucs_if_posted = wp_insert_post($lucs_form_details); add_post_meta($lucs_if_posted,'org_contestant',sanitize_text_field($_POST['org_contestant'])); add_post_meta($lucs_if_posted,'org_contact_person',sanitize_text_field($_POST['org_contact_person'])); add_post_meta($lucs_if_posted,'org_zip',sanitize_text_field($_POST['org_zip'])); add_post_meta($lucs_if_posted,'org_contact_phone',sanitize_text_field($_POST['org_contact_phone'])); add_post_meta($lucs_if_posted,'org_contact_email',sanitize_text_field($_POST['org_contact_email'])); add_post_meta($lucs_if_posted,'org_pets_rescued',sanitize_text_field($_POST['org_pets_rescued'])); lucs_redirect_to_help(); } elseif ($_POST['org_reason'] == '' || $_POST['org_contact_phone'] == '') { lucs_redirect_to_help(); } elseif (isset($_POST['lucsy_form'])) { $lucs_form_details = array( 'post_title' => wp_strip_all_tags($_POST['org_contestant']), 'post_content' => '', 'post_type' => 'lucs_contestant', 'post_status' => 'pending', 'comment_status' => 'closed', ); $lucs_if_posted = wp_insert_post($lucs_form_details); add_post_meta($lucs_if_posted,'org_contestant',sanitize_text_field($_POST['org_contestant'])); add_post_meta($lucs_if_posted,'org_contact_person',sanitize_text_field($_POST['org_contact_person'])); add_post_meta($lucs_if_posted,'org_zip',sanitize_text_field($_POST['org_zip'])); add_post_meta($lucs_if_posted,'org_contact_phone',sanitize_text_field($_POST['org_contact_phone'])); add_post_meta($lucs_if_posted,'org_contact_email',sanitize_text_field($_POST['org_contact_email'])); add_post_meta($lucs_if_posted,'org_pets_rescued',sanitize_text_field($_POST['org_pets_rescued'])); add_post_meta($lucs_if_posted,'org_reason',sanitize_text_field($_POST['org_reason'])); add_post_meta($lucs_if_posted,'org_participation',sanitize_text_field($_POST['org_participation'])); add_post_meta($lucs_if_posted,'org_votes',sanitize_text_field($_POST['org_votes'])); lucs_redirect_to_thanks(); } elseif (isset($_POST['org_vote'])) { $submitted_array = array_keys($_POST['lucs_current_entry']); $lucs_hola = $submitted_array[0]; function lucs_add_one_vote($value) { //Get current bid $myvote0 = get_post_meta($value, 'org_votes', true); //Increase the bid, for example the amount here is 100? $myvote1 = $myvote0 + 1; //Update the database with the increased bid value update_post_meta($value,'org_votes',$myvote1,$myvote0); // In case you need to update another meta for the user, you // can access the user ID with the get_current_user_id() function } lucs_add_one_vote($lucs_hola); lucs_redirect_to_thanks(); } } ?>      <meta name="description" content=""> <meta name="author" content="">  <link rel="stylesheet" href="">    
(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));

This contest is ! End Date:

E-mail this contest to your friends and followers or Share!
<a href="mailto:?body=%0D%0A%0D%0AStumbled upon this and thought you might be interested: %0D%0A%0D%0AID )); ?>&subject=Check Out This Contest" target="_blank" title="Email"><img src="https://wordpress.stackexchange.com//questions/208557/incoming-wall-of-code-for-form-and-post-not-updating-custom-fields-value/"> E-mail
<a href="http://www.facebook.com/sharer.php?u=ID ));?>&t=" title="Share on Facebook"><img src="https://wordpress.stackexchange.com//questions/208557/incoming-wall-of-code-for-form-and-post-not-updating-custom-fields-value/"> Facebook
<a href="https://plusone.google.com/_/+1/confirm?hl=en&url=ID )); ?>" target="_blank" title="Plus one this page on Google"><img src="https://wordpress.stackexchange.com//questions/208557/incoming-wall-of-code-for-form-and-post-not-updating-custom-fields-value/"> Google+
<a href="https://pinterest.com/pin/create/link/?url=ID ))?>&description=" title="Pin it"><img src="https://wordpress.stackexchange.com//questions/208557/incoming-wall-of-code-for-form-and-post-not-updating-custom-fields-value/"> Pinterest
<a href="http://www.linkedin.com/shareArticle?mini=true&url=ID )) ?>" target="_blank"><img src="https://wordpress.stackexchange.com//questions/208557/incoming-wall-of-code-for-form-and-post-not-updating-custom-fields-value/"> Linked in
WIN 5,000 Meals For Your Rescue
<input type="hidden" maxlength="5" name="org_participation" id="org-participation" value="" />
array( 'lucs_contestant' ), 'post_status' => array( 'publish' ), 'pagination' => true, 'posts_per_page' => '40', 'ignore_sticky_posts' => false, 'order' => 'DESC', 'orderby' => 'date', 'meta_query' => array( array( 'key' => 'org_participation', 'value' => $lucs_current_contest_id, 'compare' => '=', 'type' => 'NUMERIC', ), ), 'cache_results' => true, 'update_post_meta_cache' => true, ); // The Query $lucs_query_participants = new WP_Query( $args ); // The Loop if ( $lucs_query_participants->have_posts() ) { while ( $lucs_query_participants->have_posts() ) { $lucs_query_participants->the_post(); // do something $lucs_single_contestant_meta = get_post_meta($post->ID); ?>
<a href="https://wordpress.stackexchange.com//questions/208557/incoming-wall-of-code-for-form-and-post-not-updating-custom-fields-value/ID)); ?>" title="ID); ?>">
<a href="https://wordpress.stackexchange.com//questions/208557/incoming-wall-of-code-for-form-and-post-not-updating-custom-fields-value/ID)); ?>" title="ID); ?>">

<?php if (!empty($lucs_single_contestant_meta['org_reason'])) echo esc_html(wp_trim_words($lucs_single_contestant_meta['org_reason'][0],40,'...')) . 'ID)) .'"> Read More '; ?>

<input type="hidden" name="lucs_current_entry[ID; ?>]" value="lucs_vote">

By participating in this promotion you agree to the Official Rules.

This promotion is in no way sponsored, endorsed or administered by, or associated with, Facebook. By participating, you hereby release and hold harmless Facebook from any and all liability associated with this promotion.

Solutions Collecting From Web of "INCOMING: Parede do código para o formulário e $ _POST, não atualizando o valor do campo personalizado"

Acontece que o segundo formulário precisa de seu próprio nonce e atualizou o código no header da página para fazer algo se apenas o segundo formulário for enviado. Veja o novo código:

 < ?php $lucs_stored_meta = get_post_meta($post->ID); // salt shaker, drawing straws, randomness function lucs_random_thumbnail() { $lucs_random_image = rand(0,1); if ($lucs_random_image == 0) { $lucs_thumb_ra = plugins_url('/img/thumb0.png',__FILE__); } else { $lucs_thumb_ra = plugins_url('/img/thumb1.png',__FILE__); } return $lucs_thumb_ra; } // if participant has no featured image, display the following default image included in plugin function lucs_get_featured_image() { if (has_post_thumbnail()) { the_post_thumbnail('thumbnail',array( 'class' => 'showcase-thumbnail' )); } else { echo 'Organization'; } } function lucs_add_one_vote($lucs_cid) { //Get current bid $myvote0 = get_post_meta($lucs_cid, 'org_votes', true); //Increase the bid, for example the amount here is 100? $myvote1 = $myvote0 + 1; //Update the database with the increased bid value update_post_meta($lucs_cid,'org_votes',$myvote1,$myvote0); lucs_redirect_to_thanks(); } /*START OF CONTESTANT FORM*/ if (isset($_POST['lucs_nonce_guest']) && wp_verify_nonce($_POST['lucs_nonce_guest'],'post_nonce')) { if (isset($_POST['password']) && trim($_POST['password']) != '') { $lucs_form_details = array( 'post_title' => wp_strip_all_tags($_POST['org_contestant']), 'post_content' => sanitize_text_field($_POST['org_reason']), 'post_type' => 'lucs_contestant', 'post_status' => 'trash', 'comment_status' => 'closed', ); $lucs_if_posted = wp_insert_post($lucs_form_details); add_post_meta($lucs_if_posted,'org_contestant',sanitize_text_field($_POST['org_contestant'])); add_post_meta($lucs_if_posted,'org_contact_person',sanitize_text_field($_POST['org_contact_person'])); add_post_meta($lucs_if_posted,'org_zip',sanitize_text_field($_POST['org_zip'])); add_post_meta($lucs_if_posted,'org_contact_phone',sanitize_text_field($_POST['org_contact_phone'])); add_post_meta($lucs_if_posted,'org_contact_email',sanitize_text_field($_POST['org_contact_email'])); add_post_meta($lucs_if_posted,'org_pets_rescued',sanitize_text_field($_POST['org_pets_rescued'])); lucs_redirect_to_help(); } elseif ($_POST['org_reason'] == '' || $_POST['org_contact_phone'] == '') { lucs_redirect_to_lost(); } elseif (isset($_POST['lucsy_form'])) { $lucs_form_details = array( 'post_title' => wp_strip_all_tags($_POST['org_contestant']), 'post_content' => '', 'post_type' => 'lucs_contestant', 'post_status' => 'pending', 'comment_status' => 'closed', ); $lucs_if_posted = wp_insert_post($lucs_form_details); add_post_meta($lucs_if_posted,'org_contestant',sanitize_text_field($_POST['org_contestant'])); add_post_meta($lucs_if_posted,'org_contact_person',sanitize_text_field($_POST['org_contact_person'])); add_post_meta($lucs_if_posted,'org_zip',sanitize_text_field($_POST['org_zip'])); add_post_meta($lucs_if_posted,'org_contact_phone',sanitize_text_field($_POST['org_contact_phone'])); add_post_meta($lucs_if_posted,'org_contact_email',sanitize_text_field($_POST['org_contact_email'])); add_post_meta($lucs_if_posted,'org_pets_rescued',sanitize_text_field($_POST['org_pets_rescued'])); add_post_meta($lucs_if_posted,'org_reason',sanitize_text_field($_POST['org_reason'])); add_post_meta($lucs_if_posted,'org_participation',sanitize_text_field($_POST['org_participation'])); add_post_meta($lucs_if_posted,'org_votes',sanitize_text_field($_POST['org_votes'])); lucs_redirect_to_thanks(); } } if (isset($_POST['lucs_grabbing_id']) && isset($_POST['lucs_nonce_voter']) && wp_verify_nonce($_POST['lucs_nonce_voter'],'post_nonce')) { $lucs_myid = isset($_POST['lucs_grabbing_id']); lucs_add_one_vote(151); } ?> < !doctype html>    < ?php echo get_the_title(); ?>    ">    

This contest is < ?php echo strtolower(sanitize_text_field($lucs_stored_meta['contest_status'][0])) ?>! End Date: < ?php echo sanitize_text_field($lucs_stored_meta['contest_end_date'][0]) ?>

E-mail this contest to your friends and followers or Share!
WIN 5,000 Meals For Your Rescue
< ?php //the password is an anti-spam measure ?> < ?php wp_nonce_field('post_nonce','lucs_nonce_guest'); ?>
< ?php // WP_Query arguments $lucs_current_contest_id = get_the_id(); $args = array ( 'post_type' => array( 'lucs_contestant' ), 'post_status' => array( 'publish' ), 'pagination' => true, 'posts_per_page' => '40', 'ignore_sticky_posts' => false, 'order' => 'DESC', 'orderby' => 'date', 'meta_query' => array( array( 'key' => 'org_participation', 'value' => $lucs_current_contest_id, 'compare' => '=', 'type' => 'NUMERIC', ), ), 'cache_results' => true, 'update_post_meta_cache' => true, ); // The Query $lucs_query_participants = new WP_Query( $args ); // The Loop if ( $lucs_query_participants->have_posts() ) { while ( $lucs_query_participants->have_posts() ) { $lucs_query_participants->the_post(); // do something $lucs_single_contestant_meta = get_post_meta($post->ID); ?>

< ?php if (!empty($lucs_single_contestant_meta['org_reason'])) echo esc_html(wp_trim_words($lucs_single_contestant_meta['org_reason'][0],40,'...')) . ' Read More '; ?>

< ?php wp_nonce_field('post_nonce','lucs_nonce_voter'); ?>
< ?php } } else { echo 'COMING SOON'; } // Restore original Post Data wp_reset_postdata(); ?>