• Resolved botguy

    (@botguy)


    I am limited in my wordpress/s2Member knowledge, but I do know my way around php. I’ve built a site on s2Member and I need to be able to auto-assign them a field that contains an id number that increments automatically with each registration.

    The ID number can’t be their user ID number, it’s an internal number that begins at a certain number and helps to identify all of their interactions with other aspects of our business.

    I’ve looked at something like http://www.s2member.com/kb/pro-forms/#custom-data-w-pro-forms, but I don’t want to create an additional template, just some sort of function that fires when a user registers and creates a new data point for an internal ID system.

    I figure there is a simple way and I am just not as familiar with this as I should be.

    https://wordpress.org/plugins/s2member/

Viewing 1 replies (of 1 total)
  • Thread Starter botguy

    (@botguy)

    Alright, I got the code working, in case anyone is interested. I take the ID of the user and add 150 to it in this version (ours internally is a different system). It also includes auto-logging in anyone who registers:

    add_action('ws_plugin__s2member_during_configure_user_registration', 's2_auto_login_after_registration');
    function s2_auto_login_after_registration($vars = array()) {
        if (!is_admin() && $vars['processed'] === 'yes') {
            wp_new_user_notification($vars['user_id'], $vars['pass']);
            wp_set_auth_cookie($vars['user_id'], false, is_ssl());
            //begin assigning id codes
            $numbertoadd = "150";
            $idnumber = $vars['user_id'];
            $idcode = $numbertoadd + $idnumber;
            settype($idcode, "string");
            $custom_fields = get_user_option('s2member_custom_fields', $vars['user_id']);
            $custom_fields['id_code'] = $idcode;
            update_user_option($vars['user_id'], 's2member_custom_fields', $custom_fields);
            //end assigning team codes
            wp_redirect(S2MEMBER_LOGIN_WELCOME_PAGE_URL . '?first');
            exit();
        }
    }
Viewing 1 replies (of 1 total)

The topic ‘Adding an ID number to each user?’ is closed to new replies.