Hi,
I’m trying to get the references of my fields, but is not working.
I saw that only work if I save my post, because this information is on postmeta.
core/api.php : 38
$return = get_post_meta($post_id, '_' . $field_name, true);
I have to get the “field_key” before saving the values.
To update I’m usuing the function below:
update_field( $key, $value, $post_id );
How can I get the keys that are registered via ‘register_field_group’ before save my fields?
Thanks
I solved my problem reading the code of acf_form. I got this code:
$post_id = 1;
if ( strpos( $post_id, 'user_' ) !== false ) {
$filter = array( 'ef_user' => str_replace( 'user_', '', $post_id ) );
} elseif ( strpos( $post_id, 'taxonomy_' ) !== false ) {
$filter = array( 'ef_taxonomy' => str_replace( 'taxonomy_', '', $post_id ) );
} else {
$filter = array( 'post_id' => $post_id );
}
$field_groups = apply_filters( 'acf/location/match_field_groups', array(), $filter );
$acfs = apply_filters( 'acf/get_field_groups', array() );
if ( is_array( $acfs ) && is_array( $field_groups ) ) {
foreach( $acfs as $acf ) {
if ( in_array( $acf['id'], $field_groups ) ) {
$fields = apply_filters( 'acf/field_group/get_fields', array(), $acf['id'] );
}
}
}