Action hook 'user_register'

in WP Core File wp-includes/user.php at line 2621

View Source

user_register

Action Hook
Description
Fires immediately after a new user is registered.

Hook Information

File Location wp-includes/user.php View on GitHub
Hook Type Action
Line Number 2621

Hook Parameters

Type Name Description
int $user_id User ID.
array $userdata The raw array of data passed to wp_insert_user().

Usage Examples

Basic Usage
<?php
// Hook into user_register
add_action('user_register', 'my_custom_function', 10, 2);

function my_custom_function($user_id, $userdata) {
    // Your custom code here
}

Source Code Context

wp-includes/user.php:2621 - How this hook is used in WordPress core
<?php
2616  		 * @since 5.8.0 The `$userdata` parameter was added.
2617  		 *
2618  		 * @param int   $user_id  User ID.
2619  		 * @param array $userdata The raw array of data passed to wp_insert_user().
2620  		 */
2621  		do_action( 'user_register', $user_id, $userdata );
2622  	}
2623  
2624  	return $user_id;
2625  }
2626  

PHP Documentation

<?php
/**
		 * Fires immediately after a new user is registered.
		 *
		 * @since 1.5.0
		 * @since 5.8.0 The `$userdata` parameter was added.
		 *
		 * @param int   $user_id  User ID.
		 * @param array $userdata The raw array of data passed to wp_insert_user().
		 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-includes/user.php
Related Hooks

Related hooks will be displayed here in future updates.