WordPress开发者和主题制作者的搜索引擎



wpmu_log_new_registrations ›

Since5.1.0
已弃用n/a
wpmu_log_new_registrations ( $blog_id, $user_id )
参数: (2)
  • (WP_Site|int) $blog_id The new site's object or ID.
    Required: Yes
  • (int|array) $user_id User ID, or array of arguments including 'user_id'.
    Required: Yes
定义在:
文档:
Change Log:
  • MU

Logs the user email, IP, and registration date of a new site.



源码

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