Compatible with Allow Multiple Accounts plugin?
-
Hi,
I need a registration solution which allows multiple accounts to use the same e-mail address. I tried to do this using Profile Builder (with a default value in the email field) and the Allow Multiple Accounts plugin, but I still get the “this email address is already in use” error message.
Do you know of a plugin/code that will accomplish this with Profile Builder? Really want to use your plugin for this.
Thanks!
-
By the way, I understand the importance of the e-mail address for security, but in this case the website is not publicly accessible.
Hi Jeff,
Theoretically you could write a piece of code to make the two compatible, however, for it to work correctly it’s just to much work for something that’s an edge case.
You can use this code to register users via out register form with the same email address, however, I do not know how this impacts the password reset or edit profile forms:
/* * Remove the email validation for email already exists. */ function wppb_allow_multiple_accounts_email( $message, $field, $request_data, $form_location ){ global $wpdb; if ( ( isset( $request_data['email'] ) && ( trim( $request_data['email'] ) == '' ) ) && ( $field['required'] == 'Yes' ) ) return wppb_required_field_error($field["field-title"]); if ( isset( $request_data['email'] ) && !is_email( trim( $request_data['email'] ) ) ){ return __( 'The email you entered is not a valid email address.', 'profilebuilder' ); } if ( empty( $request_data['email'] ) ) { return __( 'You must enter a valid email address.', 'profilebuilder' ); } $wppb_generalSettings = get_option( 'wppb_general_settings' ); if ( is_multisite() || ( !is_multisite() && ( isset( $wppb_generalSettings['emailConfirmation'] ) && ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) ) ) ){ $user_signup = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".$wpdb->base_prefix."signups WHERE user_email = %s", $request_data['email'] ) ); if ( !empty( $user_signup ) ){ if ( $form_location == 'register' ){ return __( 'This email is already reserved to be used soon.', 'profilebuilder' ) .'<br/>'. __( 'Please try a different one!', 'profilebuilder' ); } else if ( $form_location == 'edit_profile' ){ $current_user = wp_get_current_user(); if( ! current_user_can( 'edit_users' ) ) { if ( $current_user->user_email != $request_data['email'] ) return __( 'This email is already reserved to be used soon.', 'profilebuilder' ) .'<br/>'. __( 'Please try a different one!', 'profilebuilder' ); } } } } $users = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE user_email = %s", $request_data['email'] ) ); if ( !empty( $users ) ){ if ( $form_location == 'register' ){ //return __( 'This email is already in use.', 'profilebuilder' ) .'<br/>'. __( 'Please try a different one!', 'profilebuilder' ); //var_dump( $message ); return ''; } if ( $form_location == 'edit_profile' ){ if( isset( $_GET['edit_user'] ) && ! empty( $_GET['edit_user'] ) ) $current_user_id = $_GET['edit_user']; else{ $current_user = wp_get_current_user(); $current_user_id = $current_user->ID; } foreach ( $users as $user ) if ( $user->ID != $current_user_id ) return __( 'This email is already in use.', 'profilebuilder' ) .'<br/>'. __( 'Please try a different one!', 'profilebuilder' ); } } return $message; } add_filter( 'wppb_check_form_field_default-e-mail', 'wppb_allow_multiple_accounts_email', 20, 4 ); add_action('plugins_loaded', 'wppb_remove_email_validation'); function wppb_remove_email_validation(){ remove_filter( 'wppb_check_form_field_default-e-mail', 'wppb_check_email_value', 10, 4 ); }I forgot to mention, that code needs to be placed in a custom plugin or in your theme’s functions.php
Hi Cristian,
Thanks for your reply. I put your code in my child theme’s function.php file, but I get a 500 error message, so something’s not right. Any ideas?
Best regards,
JeffDo you have a proper <?php opening and ending ?>
Yes, I do.
I could pm you the log in credentials?
better yet you should just send me the entire functions.php file. Just archive it and send a dropbox link or paste everything in it here http://pastebin.com/
It’s basically your code. I haven’t got anything else in there at the moment.
Update!
I made a new function.php file with your code and it works perfectly! I must’ve made a mistake somewhere.
Thanks for your help!
Best regards,
JeffGlad that worked out for you!
Also, I was wondering, once you will have started using PB for a while, will it be too much to ask for you to leave a review of PB on http://ww.wp.xz.cn/support/view/plugin-reviews/profile-builder ? One or two sentences will do it and it may help us to reach more people as well as get feedback from existing users.
Oh wait, too fast.
I can add users in the front end without e-mail address, but the newly registrated users don’t show up in de user list in wp-admin.
I get the user created message, but user is not really created. I checked the db and no new user is added.
Make sure Allow Multiple Accounts is active and configured. The two plugins should now work.
Basically you need to have the email address added to Allow Multiple Accounts settings or enable it for all emails.
Works like a charm!
I thought your solution worked independantly of allow multiple accounts, but I get it now. Activated the Allow Multiple Accounts plugin and works great.
BR
Jeff
The topic ‘Compatible with Allow Multiple Accounts plugin?’ is closed to new replies.