Exemplo n.º 1
0
function bp_core_signup_user($user_login, $user_password, $user_email, $usermeta)
{
    global $bp, $nxtdb;
    // Multisite installs have their own install procedure
    if (is_multisite()) {
        nxtmu_signup_user($user_login, $user_email, $usermeta);
        // On multisite, the user id is not created until the user activates the account
        // but we need to cast $user_id to pass to the filters
        $user_id = false;
    } else {
        $errors = new nxt_Error();
        $user_id = nxt_insert_user(array('user_login' => $user_login, 'user_pass' => $user_password, 'display_name' => sanitize_title($user_login), 'user_email' => $user_email));
        if (is_nxt_error($user_id) || empty($user_id)) {
            $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'buddypress'), get_option('admin_email')));
            return $errors;
        }
        // Update the user status to '2' which we will use as 'not activated' (0 = active, 1 = spam, 2 = not active)
        $nxtdb->query($nxtdb->prepare("UPDATE {$nxtdb->users} SET user_status = 2 WHERE ID = %d", $user_id));
        // Set any profile data
        if (bp_is_active('xprofile')) {
            if (!empty($usermeta['profile_field_ids'])) {
                $profile_field_ids = explode(',', $usermeta['profile_field_ids']);
                foreach ((array) $profile_field_ids as $field_id) {
                    if (empty($usermeta["field_{$field_id}"])) {
                        continue;
                    }
                    $current_field = $usermeta["field_{$field_id}"];
                    xprofile_set_field_data($field_id, $user_id, $current_field);
                }
            }
        }
    }
    $bp->signup->username = $user_login;
    /***
     * Now generate an activation key and send an email to the user so they can activate their account
     * and validate their email address. Multisite installs send their own email, so this is only for single blog installs.
     *
     * To disable sending activation emails you can user the filter 'bp_core_signup_send_activation_key' and return false.
     */
    if (apply_filters('bp_core_signup_send_activation_key', true)) {
        if (!is_multisite()) {
            $activation_key = nxt_hash($user_id);
            update_user_meta($user_id, 'activation_key', $activation_key);
            bp_core_signup_send_validation_email($user_id, $user_email, $activation_key);
        }
    }
    do_action('bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta);
    return $user_id;
}
Exemplo n.º 2
0
function validate_user_signup()
{
    $result = validate_user_form();
    extract($result);
    if ($errors->get_error_code()) {
        signup_user($user_name, $user_email, $errors);
        return false;
    }
    if ('blog' == $_POST['signup_for']) {
        signup_blog($user_name, $user_email);
        return false;
    }
    nxtmu_signup_user($user_name, $user_email, apply_filters('add_signup_meta', array()));
    confirm_user_signup($user_name, $user_email);
    return true;
}
Exemplo n.º 3
0
            nxt_redirect($redirect);
            die;
        }
    } else {
        // Adding a new user to this blog
        $user_details = nxtmu_validate_user_signup($_REQUEST['user_login'], $_REQUEST['email']);
        unset($user_details['errors']->errors['user_email_used']);
        if (is_nxt_error($user_details['errors']) && !empty($user_details['errors']->errors)) {
            $add_user_errors = $user_details['errors'];
        } else {
            $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
            if (isset($_POST['noconfirmation']) && is_super_admin()) {
                add_filter('nxtmu_signup_user_notification', '__return_false');
                // Disable confirmation email
            }
            nxtmu_signup_user($new_user_login, $_REQUEST['email'], array('add_to_blog' => $nxtdb->blogid, 'new_role' => $_REQUEST['role']));
            if (isset($_POST['noconfirmation']) && is_super_admin()) {
                $key = $nxtdb->get_var($nxtdb->prepare("SELECT activation_key FROM {$nxtdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST['email']));
                nxtmu_activate_signup($key);
                $redirect = add_query_arg(array('update' => 'addnoconfirmation'), 'user-new.php');
            } else {
                $redirect = add_query_arg(array('update' => 'newuserconfimation'), 'user-new.php');
            }
            nxt_redirect($redirect);
            die;
        }
    }
}
$title = __('Add New User');
$parent_file = 'users.php';
$do_both = false;