Missed the ACF Pro update. So I see its not using postmeta anymore…
Here’s the updated code for anyone thats looking.
function update_message_field($field_key='', $message='')
{
global $wpdb;
$table = $wpdb->prefix.'posts';
$field = $wpdb->get_results("SELECT * FROM $table WHERE post_name = '$field_key' AND post_type='acf-field'");
if($field)
{
$meta = unserialize($field[0]->post_content);
$meta['message'] = $message;
$wpdb->update(
$table,
array(
'post_content'=>serialize($meta)
),
array('post_name'=>$field_key, 'post_type'=>'acf-field'),
array('%s')
);
}
}
I’ve cobbled together a quick solution to do this.
Anyone have a better idea let me know!
update_message_field('field_53f8663f25abd', '<b>My message</b>');
function update_message_field($field_key='', $message='')
{
global $wpdb;
$table = $wpdb->prefix.'postmeta';
$field = $wpdb->get_results("SELECT * FROM $table WHERE meta_key = '$field_key'");
if($field)
{
$meta = unserialize($field[0]->meta_value);
$meta['message'] = $message;
$wpdb->update(
$table,
array(
'meta_value'=>serialize($meta)
),
array('meta_key'=>$field_key),
array('%s')
);
}
}
Cheers Elliot! Have a great Christmas.
Adam
Hi Elliot, I’ve checked this again, and all appears to be fine now! So I’m not quite sure what this could have been, whether its just a case of needing to log out/in after updating I’m not sure. But I’ll keep an eye on it just in case it occurs again and do a full debug if it does.
Cheers for looking into it though, apologies for the false alarm!
Thanks,
Adam
Quick note I’ve found a temporary way around this issue, by triggering a change event on acf.conditional_logic after the new page AJAX has loaded, I had to give it a slight delay but this is working for me:
input.js (unminified), line 919’s AJAX call, in the success callback I added:
setTimeout(function(){acf.conditional_logic.change();},100);
Hey,
I’m encountering this issue too, for any type when you do the following:
– Have a custom field set only appear when the logic meets the criteria:
Page is a child of —
– In that field set I have a select box with 3 options that act as the logic to display 3 different field sections based on that selection
When you switch the page attributes of the new post to be the top level page (so that the new page is a child) and the fields change, the conditional logic doesn’t take effect until you change the select option to be a different option other than the default.
Essentially I think when the field set first appears it needs the conditional logic to run through to make sure what should appear there by default does.
Cheers, great plugin though!
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.