Home › Forums › General Issues › Update_Field not working › Reply To: Update_Field not working
Hi @guit4eva
If the field didn’t exist beforehand in the DB (created in some other way than this) you need to use the field key rather than the field name as the first parameter for update_field()
.
As a sidenote you do not need to concatenate the strings with empty ” at the end 🙂
Example:
<?php
$displayed_user = 'user_' . bp_displayed_user_id(); // Get User ID
$assessments_repeater = get_field( 'assessments', $displayed_user ); // Get Assessments Repeater field
$ass_latest = end($assessments_repeater); // Get last row of repeater
$current_level = get_field( 'current_level', $displayed_user ); //Get current level
$ass_latest_rating = $ass_latest['ass_rating']; // Get latest rating
$ass_at = $ass_latest['assessed_at']; // Get latest level assessed at
if( $ass_latest_rating != 1 ) {
update_field( 'fieldkey goes here', $ass_at, $displayed_user );
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN
— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.
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.