Support

Account

Home Forums ACF PRO acf/save_post not firing on new server

Unread

acf/save_post not firing on new server

  • Edit: I’ve opened a ticket to discuss this matter. Turns out when W3 Total Cache is enabled, acf_save/post won’t fire. I’ll update this post with any potential future updates!

    Hi guys, sorry if this might sound dumb to you, but I’m really struggling here and backend stuff is not really my forte.

    I have a function in my functions.php that creates and assigns a category to the custom post ‘tutors’ based on an ACF Post Object dropdown selection. Basically it creates a category with the same name as the linked object:

    screenshot

    Everything was working fine on my local environment (Serverpress DesktopServer) but then I have pushed the site to production on the client’s server and the action doesn’t fire anymore.
    I have tried different priorities, from 1 to 999, but the category never gets assigned.

    Here is the function:

    
    // Assign taxonomy term with same name as the Course assigned to the Tutor
    
    function create_tutors_course($post_ID) {
    
      global $wpdb;
      $postObjectID = get_field('tutor_course', false, false); //grab the assigned Course's post ID
      if($postObjectID) {
        $catName = get_the_title($postObjectID); //grab the title of the Course
        wp_set_object_terms($post_ID, $catName, 'course_name'); //course_name is the taxonomy slug
      }
    
    }
    add_action('acf/save_post', 'create_tutors_course', 20); // This creates the term on Save
    

    I have tried replacing acf/save_post with save_post_tutors and it does fire, so the function works, however as we all know it needs to be saved twice for the change to appear, hence my need of acf/save_post.

    The only main difference between the two servers seems to be the PHP version. On my local environment, it was something like 5.7 whereas on the production server they use 7.1.3.

    This is very weird, shouldn’t the function just work on any kind of server setup?
    Thanks a lot to anybody willing to help!

    forgot to mention, I did try the usual troubleshooting, disabled any plugins except ACF. WP version is 4.8 but same issue on 4.7.x too. Set wp_debug to true but no errors on post save.

Viewing 1 post (of 1 total)

The topic ‘acf/save_post not firing on new server’ is closed to new replies.