Extra data from custom registration

[ad_1]

add_action( 'um_registration_set_extra_data', 'my_registration', 10, 2 );

function my_registration( $user_id, $args ) {
    global $wpdb;
	if ( UM()->user()->get_role() == 'um_custom_role_2' ) {
		$table_name = $wpdb->prefix . "customers";
		$fio = $_POST['first_name-151'];
		$phone = $_POST['phone_number-151'];
		$email = $_POST['user_email-151'];
		$inn = $_POST['innn-151'];
		$comp_name = $_POST['name-comp-151'];
		$address = $_POST['comp-adr-151'];
		$kpp = $_POST['kpp-151'];
		$profile_id = um_profile_id();
		
		$wpdb->insert( $table_name,  array(
			'id' => '',
			'fio' => $fio,
			'phone' => $phone,
			'email' => $email,
			'id_partner' => $profile_id,
			'inn' => $inn, 
			'company_name' => $comp_name,
			'address' => $address,
			'kpp' => $kpp),
			array('%d','%s', '%s','%s', '%s', '%s', '%s', '%s', '%s' ));
		
} 
	if ( UM()->user()->get_role() == 'um_custom_role_3' ){
		$table_name = $wpdb->prefix . "partners";
		$fio_p = $_POST['user_login-1720'];
		$phone_p = $_POST['phone_number-1720'];
		$email_p = $_POST['email-1720'];
		$company = $_POST['name-comp-1720'];

		$wpdb->insert( $table_name,  array(
			'id' => '',
			'fio_p' => $fio_p,
			'phone_p' => $phone_p,
			'email_p' => $email_p,
			'company' => $company),
			array('%d','%s', '%s','%s', '%s'));
	}
}

I have 2 roles (client and partner). For them, I created 2 different registration forms: the clients have a default one, and the partner has a custom one. Further, the data received from the form must be written to the corresponding tables. Client data is written to the database, but partner data is not. Please tell me how to solve this problem

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer