• Resolved moacirsantana

    (@moacirsantana)


    Hello, I noticed that update_field is working only for the first time and it returns TRUE, but all next changes will return FALSE.

    Not sure if that’s specific for users, here’s my code:

    $values = array( 'user_gender' => 'male', );
    $updated = update_field('custom_fields', $values, 'user_45');

    $updated will return TRUE in the first attempt and FALSE in all the others, even though it DOES update the field correctly, but that’s bad if you wanna work with conditions.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support ACF Support

    (@acfsupport)

    Hi @moacirsantana

    ACF Support Team here. This forum is generally used by ACF users to help each other out. 

    However, we would love to continue investigating and troubleshooting this issue, please can you create a ticket using our ​support form and we can look into it further.

    Boy, that would have been great to continue the conversation here since I think I’m seeing something similar.

    Thread Starter moacirsantana

    (@moacirsantana)

    @dleigh Honestly, I dont know if this was fixed or if that was an actual issue. But I’m not relying on the true/false value anymore.

    @moacirsantana I don’t think it was “fixed”.

    This page: https://www.advancedcustomfields.com/resources/update_field/ literally says this at the top:

    Return
    (bool) True on successful update, false on failure.

    and then this at the bottom:

    No change detected
    If the value passed to this function is the same as the value that is already in the database, this function returns false.

    I don’t know if they added the note to “respond” to your query, but at any rate, “false” can mean multiple things and one has to do their own complicated checking to determine if it’s a problem or not. Not the best solution, I’d say. Bummer.

    Glad you asked the question, ’cause I was seeing the same thing and really scratching my head.

    • This reply was modified 2 years, 8 months ago by dleigh.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘update_field always returns FALSE’ is closed to new replies.