#48097 closed defect (bug) (invalid)
Fix `user_registered` in WP_Insert_User function
Reported by: | mehrshaddarzi | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | |
Focuses: | Cc: |
Description
The WordPress local date [get_option( 'gmt_offset' ) * HOUR_IN_SECONDS] is not specified in the WordPress wp_insert_user
function in user_registered
parameter.
The wp-includes/user.php in Line 1724 is :
$user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered'];
change to :
$user_registered = empty( $userdata['user_registered'] ) ? current_time( 'mysql' ) : $userdata['user_registered'];
Attachments (1)
Change History (5)
#2
@
5 years ago
@SergeyBiryukov
Yes, but this is a mistake because the gmdate() PHP function not considered WordPress gmt_offset Option.hense the correct time of registration is not entered into the database. If you see other functions such as wp_insert_post function https://core.trac.wordpress.org/browser/tags/5.2.3/src/wp-includes/post.php?marks=3541#L3541 .The post_date that entered into the database exactly on the local WordPress Time.
#4
@
5 years ago
- Component changed from Users to Date/Time
- Keywords has-patch reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
For some reason I got a really delayed ping...
Sergey is correct, user creation times are explicitly meant to be in UTC in database. I don't know why, but that's the way it is set up and documented. :)
These are not consistent with posts table, e.g. there are not separate local and UTC time fields.
I suspect there very well might be issues with treating them as local time here and there through core. If so that should be reported and fixed as output bug. The storage is working as documented.
Hi @mehrshaddarzi, welcome to WordPress Trac! Thanks for the patch.
Looking at the documentation for wp_pre_insert_user_data filter, the
user_registered
parameter is intentionally a UTC timestamp, not a local time.Could you describe the problem the patch solves?