I have a function that adds and saves very well an extra field to the user profile. But, because the content of this field gets old very quickly, I need to know when the user refreshed it last time - only this specific field, not the whole user meta data! I need to know if the user REALLY updated (edited) the content of this field, not only simply pushed the update button. How to do this?

/* Add extra fields to the user profile */

add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );

function extra_user_profile_fields( $user ) { ?>

   <table class="form-table">
   <tr><th><label for="consultations_day"><?php _e("Consultation day"); ?></label></th>
      <td><textarea rows="3" cols="30" name="consultations_day" id="consultations_day" style="margin-bottom: 0px;" /><?php echo esc_attr( get_the_author_meta( 'consultations_day', $user->ID ) ); ?></textarea><br />
         <span class="description"><?php _e("Put here your consultations day and hours"); ?></span><br />

/* Save extra user profile fields */

add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );

function save_extra_user_profile_fields( $user_id ) {

   if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }

   update_user_meta( $user_id, 'consultations_day', $_POST['consultations_day'] );  //Consultations day


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.