On this page
wpmu_log_new_registrations( WP_Site|int $blog_id, int|array $user_id )
Logs the user email, IP, and registration date of a new site.
Parameters
$blog_idWP_Site|int Required-
The new site's object or ID.
$user_idint|array Required-
User ID, or array of arguments including
'user_id'.
Source
File: wp-includes/ms-functions.php. View all references
function wpmu_log_new_registrations( $blog_id, $user_id ) {
global $wpdb;
if ( is_object( $blog_id ) ) {
$blog_id = $blog_id->blog_id;
}
if ( is_array( $user_id ) ) {
$user_id = ! empty( $user_id['user_id'] ) ? $user_id['user_id'] : 0;
}
$user = get_userdata( (int) $user_id );
if ( $user ) {
$wpdb->insert(
$wpdb->registration_log,
array(
'email' => $user->user_email,
'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ),
'blog_id' => $blog_id,
'date_registered' => current_time( 'mysql' ),
)
);
}
}
Related
Uses
| Uses | Description |
|---|---|
| current_time() wp-includes/functions.php | Retrieves the current time based on specified type. |
| wpdb::insert() wp-includes/class-wpdb.php | Inserts a row into the table. |
| wp_unslash() wp-includes/formatting.php | Removes slashes from a string or recursively removes slashes from strings within an array. |
| get_userdata() wp-includes/pluggable.php | Retrieves user info by user ID. |
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | MU (3.0.0) |
| 5.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wpmu_log_new_registrations