Support

Account

Home Forums Backend Issues (wp-admin) acf/save_post only working after save on backend

Unread

acf/save_post only working after save on backend

    • adam_g

    • June 27, 2019 at 12:40 am

    I’ve created a function to updated the post title and post name within a form.

    add_action('acf/save_post', 'chiwp_update_post_name', 20);
    
    function chiwp_update_post_name($post_id)
    {
      $desired_url = get_field('show_information', $post_id);
      $desired_url = $desired_url['desired_url_extension'];
      $title = get_field('show_information', $post_id);
      $title = $title['show_name'];
    
      $data = array(
        'ID'         => $post_id,
        'post_title' => $title,
        'post_name'  => sanitize_title($desired_url),
      );
    
      wp_update_post($data);
    }

    However, the front end displays only the new title and slug info correctly initially.

    In other words, all the other form data is saved to the back end correctly, but it does not appear on the front end until I manually “save draft” in the admin. Then everything works properly.

    What am I missing within the function to save all the data at the right time?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

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.