[Plugin: Register Plus] Fix for custom fields/profile fields not being saved at registeration
-
I notice a lot of members have problems with Register Plus’ custom fields not working. The reason is if those fields are saved to the usermeta DB during the wp_new_user_notification(). If that is never run for some reason (another plugin using that), then the custom fields are not saved.
The solution is not to save those fields in wp_new_user_notification().
At the beginning of the class, look for a block of text that says this and add in a new action – user_register. This is called after a user registration request is submitted
if($_GET['action'] == 'register') { add_action( 'wp_head', array($this, 'PassHead') ); add_action ('user_register', array($this, 'SaveNewMember')); }
Then introduce this new function inside the class – the code are lifted exactly from wp_new_user_notification() (they are within the comment blocks –#REGPLUS–)
function SaveNewMember($user_id) { global $wpdb, $register_plus; $regplus = get_option( 'register_plus' ); $regplus_custom = get_option( 'register_plus_custom' ); $ref = explode( '?', $_SERVER['HTTP_REFERER']); $ref = $ref[0]; $admin = trailingslashit( get_option('siteurl') ) . 'wp-admin/users.php'; if( !is_array( $regplus_custom ) ) $regplus_custom = array(); if( $regplus['password'] && $_POST['user_pw'] ) $plaintext_pass = $wpdb->prepare($_POST['user_pw']); else if( $ref == $admin && $_POST['pass1'] == $_POST['pass2'] ) $plaintext_pass = $wpdb->prepare($_POST['pass1']); else $plaintext_pass = $register_plus->RanPass(6); if( $regplus['firstname'] && $_POST['firstname'] ) update_usermeta( $user_id, 'first_name', $wpdb->prepare($_POST['firstname'])); if( $regplus['lastname'] && $_POST['lastname'] ) update_usermeta( $user_id, 'last_name', $wpdb->prepare($_POST['lastname'])); if( $regplus['website'] && $_POST['website'] ) update_usermeta( $user_id, 'user_url', $wpdb->prepare($_POST['website'])); if( $regplus['aim'] && $_POST['aim'] ) update_usermeta( $user_id, 'aim', $wpdb->prepare($_POST['aim'])); if( $regplus['yahoo'] && $_POST['yahoo'] ) update_usermeta( $user_id, 'yim', $wpdb->prepare($_POST['yahoo'])); if( $regplus['jabber'] && $_POST['jabber'] ) update_usermeta( $user_id, 'jabber', $wpdb->prepare($_POST['jabber'])); if( $regplus['about'] && $_POST['about'] ) update_usermeta( $user_id, 'description', $wpdb->prepare($_POST['about'])); if( $regplus['code'] && $_POST['regcode'] ) update_usermeta( $user_id, 'invite_code', $wpdb->prepare($_POST['regcode'])); if( $ref != $admin && $regplus['admin_verify'] ){ update_usermeta( $user_id, 'admin_verify_user', $user->user_login ); $temp_id = 'unverified__' . $register_plus->RanPass(7); $notice = __('Your account requires activation by an administrator before you will be able to login.', 'regplus') . "\r\n"; }else if( $ref != $admin && $regplus['email_verify'] ){ $code = $register_plus->RanPass(25); update_usermeta( $user_id, 'email_verify', $code ); update_usermeta( $user_id, 'email_verify_date', date('Ymd') ); update_usermeta( $user_id, 'email_verify_user', $user->user_login ); $email_code = '?regplus_verification=' . $code; $prelink = __('Verification URL: ', 'regplus'); $notice = __('Please use the link above to verify and activate your account', 'regplus') . "\r\n"; $temp_id = 'unverified__' . $register_plus->RanPass(7); } if (!empty($regplus_custom)) { foreach( $regplus_custom as $k=>$v ){ $id = $register_plus->Label_ID($v['label']); if( $v['reg'] && $_POST[$id] ){ if( is_array( $_POST[$id] ) ) $_POST[$id] = implode(', ', $_POST[$id]); update_usermeta( $user_id, $id, $wpdb->prepare($_POST[$id])); } } } }
Of course, you should also locate the block of code inside wp_new_user_notification() and remove it to prevent the information for being added twice.
I realise that this is rather technical. Hopefully the original author can help to implement this changes.
- The topic ‘[Plugin: Register Plus] Fix for custom fields/profile fields not being saved at registeration’ is closed to new replies.