Support

Account

Home Forums General Issues Frontend Form not populating right in backend Reply To: Frontend Form not populating right in backend

  • Hi @brotsky_pixie

    I think I gave you the wrong code. I’m sorry about that. Please try this one instead:

    // create the update data holder
    $vbs_post = array();
    $vbs_post['ID'] = $post_id;
    $vbs_post['post_title'] = $new_title;

    If you want to change the post slug, please try this code:

    $vbs_post['post_name'] = 'this-is-the-new-slug';

    Please check this page for more parameters: https://developer.wordpress.org/reference/functions/wp_insert_post/.

    Also, please don’t forget to save the changes like this:

    //Unhook function to prevent infitnite looping
    remove_action('acf/save_post', 'vbs_post_title_updater', 20);
    
    // Update the post into the database
    wp_update_post( $vbs_post );
    
    //Rehook function to prevent infitnite looping
    add_filter('acf/save_post', 'vbs_post_title_updater', 20);

    Hope this helps 🙂