wpmu_log_new_registrations() WordPress Function

The wpmu_log_new_registrations() function is used to log new user registrations on a WordPress Multisite installation. This function is useful for keeping track of new user registrations and for troubleshooting user registration issues.

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_id

(WP_Site|int)(Required)The new site's object or ID.

$user_id

(int|array)(Required)User ID, or array of arguments including 'user_id'.


Top ↑

Source

File: wp-includes/ms-functions.php

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' ),
			)
		);
	}
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)MU (3.0.0)
5.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More