Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

Registration

Simple Membership Plugin › Forums › Simple Membership Plugin › Registration

Tagged: validation on registration

  • This topic has 12 replies, 4 voices, and was last updated 9 years, 3 months ago by carcangium.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • February 22, 2017 at 3:35 pm #10240
    carcangium
    Participant

    On a new registration the email is been checked only if exists on the plugin members table but if an email is already been used for an admin user. The registration goes fine but than the user won’t be able to login because the new user is not been saved in the wp_user table as the email address must be unique.

    Is there a way to hook in the validation and check the if the email exists also in wp_users?

    Many thanks

    February 22, 2017 at 10:08 pm #10246
    mbrsolution
    Moderator

    Hi, can you clarify the following comment further. Thank you.

    The registration goes fine but than the user won’t be able to login because the new user is not been saved in the wp_user table as the email address must be unique.

    February 22, 2017 at 10:19 pm #10247
    info
    Participant

    when a user try to register with an email address which was already used from an admin user, it does not give any error and after when he/she try logging in it won’t let him/her. the page reloads and no error is given.

    February 22, 2017 at 10:39 pm #10249
    mbrsolution
    Moderator

    That is very strange. If the e-mail address exists anywhere in your site the plugin will not allow a user to register with that e-mail address. Can you check the server log files and see if there is any information related to the registration process. Are you currently using the Form Builder addon?

    February 22, 2017 at 11:11 pm #10253
    info
    Participant

    Yes I am also using the form builder addon and I have created a custom registration form.

    February 22, 2017 at 11:18 pm #10255
    mbrsolution
    Moderator

    Hi, please make sure you are running the Form Builder latest version. Click on the following URL re-download-the purchased add-ons. to check.

    Thank you

    February 23, 2017 at 9:21 am #10266
    carcangium
    Participant

    My email is not being recognized!

    February 23, 2017 at 10:57 am #10268
    carcangium
    Participant

    I have fixed it by modifying the code in “class.swpm-ajax.php”
    You can see from the code below that I have commented out $table and $query and wrote my own so it’s now checking if the email and the user_name exists in wp_users instead:

    
    class SwpmAjax {
        public static function validate_email_ajax() {
            global $wpdb;
            $field_value = filter_input(INPUT_GET, 'fieldValue');
            $field_id = filter_input(INPUT_GET, 'fieldId');
            $member_id = filter_input(INPUT_GET, 'member_id');
            if (!is_email($field_value)){
                echo '[ "' . $field_id .  '",false, "'.SwpmUtils::_('Invalid Email Address').'" ]' ;
                exit;
            }
            // $table = $wpdb->prefix . "swpm_members_tbl";
            // $query = $wpdb->prepare("SELECT member_id FROM $table WHERE email = %s AND user_name != ''", $field_value);
            $table = $wpdb->prefix . "users";
            $query = $wpdb->prepare("SELECT ID FROM $table WHERE email = %s AND user_login != ''", $field_value);
            $db_id = $wpdb->get_var($query) ;
            $exists = ($db_id > 0) && $db_id != $member_id;
            echo '[ "' . $field_id . (($exists) ? '",false, "χ '.SwpmUtils::_('Aready taken').'"]' : '",true, "√ Available"]');
            exit;
        }
    
        public static function validate_user_name_ajax() {
            global $wpdb;        
            $field_value = filter_input(INPUT_GET, 'fieldValue');
            $field_id = filter_input(INPUT_GET, 'fieldId');
            if (!SwpmMemberUtils::is_valid_user_name($field_value)){
                echo '[ "' . $field_id . '",false,"χ '. SwpmUtils::_('Name contains invalid character'). '"]';
                exit;
            }
            // $table = $wpdb->prefix . "swpm_members_tbl";
            // $query = $wpdb->prepare("SELECT COUNT(*) FROM $table WHERE user_name = %s", $field_value);
            $table = $wpdb->prefix . "users";
            $query = $wpdb->prepare("SELECT COUNT(*) FROM $table WHERE user_login = %s", $field_value);
            $exists = $wpdb->get_var($query) > 0;
            echo '[ "' . $field_id . (($exists) ? '",false,"χ '. SwpmUtils::_('Aready taken'). '"]' :
                '",true,"√ '.SwpmUtils::_('Available'). '"]');
            exit;
        }
    }
    

    Many thanks

    February 23, 2017 at 9:10 pm #10271
    mbrsolution
    Moderator

    That is great news :). Just remember that when you update the plugin again you will loose your custom code. So I suggest that you make a backup of this file and keep it safe.

    Regards

    February 23, 2017 at 10:30 pm #10272
    info
    Participant

    I will do.

    But I suggest you get this done for the next update.

    Many thanks

    February 23, 2017 at 11:22 pm #10273
    mbrsolution
    Moderator

    The plugin developers will investigate further your suggestion.

    Regards

    February 25, 2017 at 2:27 am #10288
    admin
    Keymaster

    The code modification you suggested can’t be implemented in the plugin. It doesn’t factor in the reasons we have the check the way we have it now. We want to allow users to be able to connect an old wp user record (non-admin user) to a SWPM account. If a user has a wp user record on the site before and is now creating a member account, he should be able to connect the newly created swpm account with his existing wp user record.

    February 27, 2017 at 8:46 am #10296
    carcangium
    Participant

    What is it supposed to happen if is used an email already used by an admin?

    Because we have tried registering a new user with same email of an existing admin user. The registration gets submitted successfully without returning any error. Then when we try logging in with the new user, it won’t work.

    Regards

    Marco

  • Author
    Posts
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy