PHP user_register wordpress function

Today, We want to share with you user_register.In this post we will show you How to add additional information to a user on user creation?, hear for woocommerce user register hook we will give you demo and example for implement.In this post, we will learn about Woocommerce Product publish, update and delete hooks with an example.

Get first_name and last_name on user_registers hook

The WordPress Core user register hook.

add_action( 'user_register',  $array ); 

Free Live Chat for Any Issue

Usage

// run the action 
do_action( 'user_register', $array ); 
 
function action_user_register( $array ) { 
    print_r($array);
}; 
add_action( 'user_register', 'action_user_register', 10, 1 );

wishlist user register

add_action('user_register', 'get_all_users_list');
function get_all_users_list($user_id) {
	global $wpdb;

	if (isset($_POST['first_name'])) {
		$firstname = $_POST['first_name'];
	}
	else {
		$firstname = '';
	}
	
	$data = array (
		'user_id' => $user_id,
		'first_name' => $firstname,
	);
	$wpdb->insert('wp_my_crm_data', $data);
}

Example using get_userdata in WordPress

$info = get_userdata($user_id);
$info->first_name;
$info->last_name;

function user_registers

add_action( 'user_register', 'action_function_name_9858' );
function action_function_name_9858( $user_id ){
	print_r(user_id);
}

I hope you get an idea about Custom form hooked to user_registers.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.