Support

Account

Home Forums Backend Issues (wp-admin) Update datepicker when editing user in wp-admin

Helping

Update datepicker when editing user in wp-admin

  • Hello,
    I’m posting this message because I can’t update a datepicker field I created via your plugin. The idea is to fill this field with today’s date to create an “update date” that I could reuse later each time I click on the “Update account” button in the back office of wordpress.
    I think I’m doing it wrong but I don’t see how to fix it at all… Please find below the code I use in the function.php :

    // Is run when you edit ANY OTHER profile and save it.
    add_action('edit_user_profile_update', 'handle_user_profile_update' );
    // Manager of the user profile update function
    function handle_user_profile_update($user_id) {
        // Update date_de_mise_a_jour    
        update_modifying_date_field($user_id);
    }
    
    // Update date of modification
    function update_modifying_date_field($user_id) {	
        // Date of the update
    	$date = date("d/m/Y");
    	$date = $date->format('Ymd');
        // Update ACF field for actual $user_id
    	// Update input with "acf[field_61d848a696fbf]" as name
    	update_field('acf[field_61d848a696fbf]', $date, 'user_' . $user_id);
    }

    (I tried with “data-key” as first parameter, it doesn’t work neither, same with “data-name”)

    I’m using Advanced Custom Fields version 5.11.1

    Best regards,
    Fred

    NB : Attached is the print screen of the html I get when I add the custom field

  • 
    $date = date('Ymd');
    update_field('field_61d848a696fbf', $date, 'user_' . $user_id);
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.