Home › Forums › Backend Issues (wp-admin) › How to display Date Picker values beetween Custom Post Type to edit Profile User › Reply To: How to display Date Picker values beetween Custom Post Type to edit Profile User
function custom_save_date( $post_id )
{
// get user from user field
$user = get_field( 'user', $post_id );
// get user id from user field
$user_id = $user['ID'];
// get date changed field
$date_changed = get_field( 'date_de_fin_dabonnement', $post_id );
$date = new DateTime( $data_changed );
// set format
$date = $date->format('d/m/Y');
// update user field
update_field( 'date_de_fin_dabonnement', $date, 'user_' . $user_id );
}
// acf save post hook
add_action('acf/save_post', 'custom_save_date', 15);
ACF has its own hook. You can use them for your fields. Also, you forgot the global $post as well as the user in your example. I have not tested the code AND sorry for my english! 🙂
If you using an other output from user field, just change the output in line 7 and 17.
Useful links:
acf/save_post
ACF user field (first answer from John)
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 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.