Home › Forums › General Issues › submit data from a form › Reply To: submit data from a form
I tried that and didn’t have any luck there either…
This is my code at the moment:
function generate_grading_application_cpt() {
if (isset( $_POST['submit'] ) ) {
$formStudNum = $_POST['student-number'];
$formDojang = $_POST['dojang'];
$formInstructor = $_POST['instructor'];
$formCurrentRank = $_POST['current-rank'];
$cpt_post_args = array(
'post_title' => $_POST['full-name'],
'post_status' => 'publish',
'post_type' => 'grading_applications',
);
// Student Number Field
$field_key = "field_5ec64e12429be";
$value = $formStudNum;
update_field( $field_key, $value, $post_id );
// Dojang Field
$field_key = "field_5ec64f26429bf";
$value = $formDojang;
update_field( $field_key, $value, $post_id );
// Instructor Field
$field_key = "field_5ec64f36429c0";
$value = $formInstructor;
update_field( $field_key, $value, $post_id );
// Current Rank Field
$field_key = "field_5ec64f5e429c1";
$value = $formCurrentRank;
update_field( $field_key, $value, $post_id );
// insert the post into the database
$cpt_id = wp_insert_post( $cpt_post_args, $wp_error);
}
};
add_action( 'template_redirect', 'generate_grading_application_cpt' );
https://imgur.com/41uMEkJ – Screen Shot of ACF fields
Anything obvious I’m missing. ACF fields are very new to me…
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!
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future.
— Advanced Custom Fields (@wp_acf) January 6, 2023
https://t.co/HahJUCcyH4
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.