• Hi!
    I trying to add a custom field to WP Multisite registration.
    I found hooks to display my field but I can’t save its value to user profile, because to do that I need user ID, but user ID, as I assumed does’t exist before user will confirm registration by link in email.
    I tryed this code:

    add_action( 'wpmu_new_user', 'phone_register_extra_fields' );
    function phone_register_extra_fields ( $user_id, $password = "", $meta = array() ) {
    	$phone_number = filter_var($_POST['phone_number'], FILTER_SANITIZE_NUMBER_INT);
    	update_user_meta( $user_id, 'phone_number', $phone_number );
    }
    

    That is not the only code, but other parts work fine.
    How can I save the field value to pending user profile that doesn’t have the ID yet?
    Thank you!

    • This topic was modified 4 years, 7 months ago by kiberchaka.
Viewing 1 replies (of 1 total)
  • Thread Starter kiberchaka

    (@kiberchaka)

    He everyone!
    I still can’t handle the promlem.
    I fount out, than it is possible to reach user ID on this hook (after activation blog):

    
    add_action( 'wpmu_activate_blog', 'mu_add_phone_after_activation', 10, 3 );
    function mu_add_phone_after_activation( $blog_id, $user_id, $password, $signup_title, $meta ) {
    	$user_phone = 'TESTnumber';
    
    	// $user_phone = $meta['user_phone']; // How to put data in the $meta['user_phone']? On which hook to take it from a $_POST['user_phone'] ?
    
    	update_user_meta( $user_id, 'phone_number', $user_phone );		
    }
    

    But I need to store the phone number from Multisite User and Blog registration form. Probably it is possible to store it in the $meta variable, but I tried a lot of hooks and didn’t succeed. May be did it wrong.

    I tried:

    
    add_filter( 'signup_user_meta', 'mu_add_phone_in_signup', 10, 4 );
    function mu_add_phone_in_signup( $meta, $domain, $path, $title, $user, $user_email, $key ) {
    
    	$meta['phone_number'] = '1111111';
    	return $meta;
    }
    
    add_filter( 'add_signup_meta', 'mu_add_phone_in_signup2', 10, 4 );
    function mu_add_phone_in_signup2( $meta_defaults = array() ) {
    	
    	$meta_defaults = array( 'phone_number'  => '11111111' );
    	return $meta_defaults;
    }
    
    add_filter( 'signup_site_meta', 'mu_add_phone_in_signup3', 10, 4 );
    function mu_add_phone_in_signup3( $domain, $path, $title, $user, $user_email, $key, $meta ) {
    
    	$meta['phone_number'] = '11111111';
    	return $meta;
    }
    
    • This reply was modified 4 years, 7 months ago by kiberchaka.
    • This reply was modified 4 years, 7 months ago by kiberchaka.
    • This reply was modified 4 years, 7 months ago by kiberchaka.
Viewing 1 replies (of 1 total)
  • The topic ‘Add custom user profile field to MultiSite registration’ is closed to new replies.