Hi,
Thanks so much for that. It now works perfectly. 🙂
Philippe
Hi again,
This is the code I used to create the frontend form:
$options = array(
'id' => 'photo-athlete',
'fields' => array( 'photo_athlete' ),
'form' => true,
'submit_value' => __("Sauvegarder votre photo", 'acf'),
'instruction_placement' => 'field',
'updated_message' => false,
'uploader' => 'wp'
);
acf_form( $options );
Thanks
Philippe
Hi,
I did try renaming the function (also in the add_action) but it does nothing. When I select the image from the backend it does get attached by default but from the front end, it does not work. I mean, the image does get saved but it’s not attached to any post.
This is the code I used:
function pb3d_acf_save_post( $post_id ) {
$file = get_field('photo_athlete', $post_id);
if( $file ){
$file_id = $file['ID'];
$post_to_update = array(
'ID' => $file_id,
'post_parent' => $post_id
);
wp_update_post( $post_to_update );
}
}
add_action('acf/save_post', 'pb3d_acf_save_post', 20);
Thanks for your help 🙂
Philippe
Hi,
I added your code to my functions.php but I got this error on the site:
“Fatal error: Cannot declare acf_save_post() (previously declared in /home/…/plugins/advanced-custom-fileds-pro/core/input.php:436) in ……..
Did I put the code in the wrong place, could I just rename the function?
Thanks for your help 🙂
Philippe