php - How to update an acf field after clicking a submit button?

I need to update text to an acf field after clicking a submit button.
The field is empty at the moment and I need to update text into the existing field.
I added the following code in a post edit page but it doesn’t update the value.
Would you please let me know how to fix the code?
I created the button below using acf widget in elementor:
<input type="submit" class="acfef-submit-button acf-button button button-primary" data-state="publish" value="EDIT">
I added the following code in a post edit page:
add_action('acf/save_post', 'update_infosubmission_field');
function update_infosubmission_field($post_id) {
$post_id = get_the_id();
$field_key = "field_606cb980986773";
$value = "yes";
update_field( $field_key, $value, $post_id);
}
Thank you.
Answer
Solution:
Just in case for someone who may need it.
The following code works:
add_action('acf/save_post', 'update_name');
function update_name($post_id) {
if (get_post_type($post_id) != 'infosub') {
return;
}
$field_key = "field_606cb980986773";
$value = "yes";
update_field( $field_key, $value, $post_id);
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: string literal contains an unescaped line break
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.