functions – WP User frontend pro not saving ACF values to Database


I am using the WP User frontend pro plugin to accept guest posts from the frontend form that contains several custom fields. Everything works fine after submitting the frontend form and even when we check the post from wp-admin, it shows all the correct custom field values correctly.

But on the frontend guest post, it’s not showing custom field values until I resave the submitted guest post from the backend. When talked to ACF support, they said that the wp user frontend pro plugin populates the custom fields but does not save them to the database. They also said to write a custom function that triggers after WP user frontend submits/updates post from frontend and run save_post() ACF function.

After discussing with the WP User frontend team, they gave the following functions triggers after post insert/update and can be used for custom actions –

  • wpuf_add_post_after_insert
  • wpuf_add_post_after_update


So I wrote the following code –

function save_to_database($post_id,$form_id){
if($form_id == "195"){
do_action( 'acf/save_post', $post_id );
add_action( 'wpuf_add_post_after_insert', 'save_to_database' , 10 ,2 );
add_action( 'wpuf_edit_post_after_update', 'save_to_database' , 10 , 2 );

But this dint work. Can anyone help me correct the above code? Or provide me with a better solution?

GoSSDHosting 1 week 2022-09-19T14:59:13-05:00 0 Answers 0 views 0

Leave an answer