예제 #1
0
/**
 * Validate a user
 *
 * @param int    $user_guid
 * @param string $code
 * @return bool
 */
function uservalidationbyemail_validate_email($user_guid, $code)
{
    $user = get_entity($user_guid);
    if ($code == uservalidationbyemail_generate_code($user_guid, $user->email)) {
        return elgg_set_user_validation_status($user_guid, true, 'email');
    }
    return false;
}
예제 #2
0
파일: functions.php 프로젝트: ibou77/elgg
/**
 * Validate a user
 *
 * @param int    $user_guid
 * @param string $code
 * @return bool
 */
function uservalidationbyemail_validate_email($user_guid, $code)
{
    $user = get_entity($user_guid);
    $site_url = elgg_get_site_url();
    $matches = elgg_build_hmac([(int) $user_guid, $user->email, $site_url])->matchesToken($code);
    if (!$matches) {
        return false;
    }
    return elgg_set_user_validation_status($user_guid, true, 'email');
}
예제 #3
0
파일: hooks.php 프로젝트: lorea/Hydra-dev
/**
 * Validate a new user if he/she comes from some social networks
 *
 * @param string $hook         the name of the hook
 * @param string $type         the type of the hook
 * @param mixed  $return_value current return value
 * @param array  $params       supplied params
 *
 * @return void
 */
function socialink_register_user_hook($hook, $type, $return_value, $params)
{
    $result = $return_value;
    if (!empty($params) && is_array($params)) {
        $user = elgg_extract("user", $params);
        if (elgg_instanceof($user, "user")) {
            $network = get_input("network");
            switch ($network) {
                case "facebook":
                case "wordpress":
                    // user is validated by facebook or wordpress
                    elgg_set_user_validation_status($user->getGUID(), true, "email");
                    break;
            }
        }
    }
    return $result;
}
예제 #4
0
 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $admin = $this->option('admin');
     $notify = $this->option('notify');
     $email = $this->ask('Enter account email: ');
     list($username, ) = explode('@', $email, 2);
     $username = $this->ask("Enter account username [{$username}]: ", $username);
     $password = $this->ask('Enter account password (leave empty to autegenerate): ', null, true, false);
     if (empty($password)) {
         $password = generate_random_cleartext_password();
     }
     $name = $this->ask("Enter account display name [{$username}]: ", $username);
     $guid = register_user($username, $password, $name, $email);
     $user = get_entity($guid);
     $user->admin_created = true;
     elgg_set_user_validation_status($user->guid, true, 'cli');
     $params = ['user' => $user, 'password' => $password];
     if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
         $ia = elgg_set_ignore_access(true);
         $user->delete();
         elgg_set_ignore_access($ia);
         throw new RegistrationException(elgg_echo('registerbad'));
     }
     if ($admin) {
         $ia = elgg_set_ignore_access(true);
         $user->makeAdmin();
         elgg_set_ignore_access($ia);
     }
     if ($notify) {
         $subject = elgg_echo('useradd:subject', array(), $user->language);
         $body = elgg_echo('useradd:body', array($name, elgg_get_site_entity()->name, elgg_get_site_entity()->url, $username, $password), $user->language);
         notify_user($user->guid, elgg_get_site_entity()->guid, $subject, $body, ['password' => $password]);
     }
     if ($user->isAdmin()) {
         system_message("New admin user has been registered [guid: {$user->guid}]");
     } else {
         system_message("New user has been registered [guid: {$user->guid}]");
     }
 }
예제 #5
0
/**
 * 
 * Disable a new user pending email verification
 * 
 * @param type $hook
 * @param type $type
 * @param type $return
 * @param type $params
 * @return type
 */
function disable_new_user($hook, $type, $value, $params)
{
    $user = elgg_extract('user', $params);
    if (!elgg_get_plugin_setting('email_validate', PLUGIN_ID)) {
        return;
    }
    // no clue what's going on, so don't react.
    if (!$user instanceof \ElggUser) {
        return;
    }
    // another plugin is requesting that registration be terminated
    // no need for uservalidationbyemail
    if (!$value) {
        return $value;
    }
    // has the user already been validated?
    if (elgg_get_user_validation_status($user->guid) == true) {
        return $value;
    }
    // disable user to prevent showing up on the site
    // set context so our canEdit() override works
    elgg_push_context('stormpath_new_user');
    $hidden_entities = access_get_show_hidden_status();
    access_show_hidden_entities(TRUE);
    // Don't do a recursive disable.  Any entities owned by the user at this point
    // are products of plugins that hook into create user and might need
    // access to the entities.
    // @todo That ^ sounds like a specific case...would be nice to track it down...
    $user->disable('stormpath_new_user', FALSE);
    // set user as unvalidated and send out validation email
    elgg_set_user_validation_status($user->guid, FALSE);
    // trigger the stormpath email validation
    elgg_pop_context();
    access_show_hidden_entities($hidden_entities);
    return $value;
}
예제 #6
0
파일: functions.php 프로젝트: elgg/elgg
/**
 * Validate a user
 *
 * @param int    $user_guid
 * @param string $code
 * @return bool
 * @deprecated 2.3
 */
function uservalidationbyemail_validate_email($user_guid, $code = null)
{
    elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated. Validation now relies on signed URL API', '2.3');
    elgg_signed_request_gatekeeper();
    return elgg_set_user_validation_status($user_guid, true, 'email');
}
예제 #7
0
            }
            if ($avatar_error) {
                foreach ($files as $file) {
                    $file->delete();
                }
            } else {
                $user->x1 = 0;
                $user->x2 = 0;
                $user->y1 = 0;
                $user->y2 = 0;
                $user->icontime = time();
                elgg_create_river_item(array('view' => 'river/user/default/profileiconupdate', 'action_type' => 'update', 'subject_guid' => $user->guid, 'object_guid' => $user->guid));
            }
            $filehandler->delete();
        }
        elgg_set_user_validation_status($user->guid, true, 'FAKER');
        if ($user->save()) {
            $success++;
            set_user_notification_setting($user->guid, 'email', false);
            set_user_notification_setting($user->guid, 'site', true);
        } else {
            $error++;
        }
    }
}
if ($errors) {
    system_message(elgg_echo('faker:gen_users:error', array($success, $error, implode('<br />', $exceptions))));
} else {
    system_message(elgg_echo('faker:gen_users:success', array($success)));
}
forward(REFERER);
예제 #8
0
/**
 * Make sure any admin users are automatically validated
 *
 * @param string   $event
 * @param string   $type
 * @param ElggUser $user
 */
function uservalidationbyemail_validate_new_admin_user($event, $type, $user)
{
    if ($user instanceof ElggUser && !$user->validated) {
        elgg_set_user_validation_status($user->guid, TRUE, 'admin_user');
    }
}
예제 #9
0
파일: register.php 프로젝트: n8b/VMN
 // note: To catch all new users, even those created by an admin,
 // register for the create, user event instead.
 // only passing vars that aren't in ElggUser.
 $params = array('user' => $new_user, 'password' => $password, 'friend_guid' => $friend_guid, 'invitecode' => $invitecode, 'photo_url' => $photo_url, 'provider' => $provider, 'provider_uid' => $provider_uid);
 $metadata = array('description' => get_input('description'), "{$provider}_url" => get_input('profile_url'), "{$provider}" => get_input($provider), 'website' => get_input('website_url'), 'first_name' => get_input('first_name'), 'last_name' => get_input('last_name'), 'gender' => get_input('gender'), 'language' => get_input('language'), 'age' => get_input('age'), 'birthdate' => mktime(0, 0, 0, get_input('birthmonth'), get_input('birthday'), get_input('birthyear')), 'contactemail' => get_input('contactemail'), 'phone' => get_input('phone'));
 foreach (array('address', 'country', 'region', 'city', 'zip') as $location_element) {
     if (get_input($location_element, false)) {
         $location[] = get_input($location_element);
     }
 }
 if ($location) {
     $metadata['location'] = implode(', ', $location);
 }
 // we have received a verified email from a provider
 if ($verified) {
     elgg_set_user_validation_status($new_user->guid, true, 'hybridauth');
 }
 foreach ($metadata as $md_name => $md_value) {
     create_metadata($new_user->guid, $md_name, $md_value, '', $new_user->guid, ACCESS_PRIVATE, true);
 }
 if ($photo_url) {
     $icon_sizes = elgg_get_config('icon_sizes');
     $filehandler = new ElggFile();
     $filehandler->owner_guid = $new_user->guid;
     foreach ($icon_sizes as $size => $dimensions) {
         $image = get_resized_image_from_existing_file($photo_url, $dimensions[0], $dimensions[1], $dimensions[2]);
         $image = get_resized_image_from_existing_file($photo_url, $dimensions['w'], $dimensions['h'], $dimensions['square'], 0, 0, 0, 0, $dimensions['upscale']);
         $filehandler->setFilename("profile/{$new_user->guid}{$size}.jpg");
         $filehandler->open('write');
         $filehandler->write($image);
         $filehandler->close();
예제 #10
0
파일: confirm.php 프로젝트: elgg/elgg
<?php

elgg_signed_request_gatekeeper();
$user_guid = get_input('u', FALSE);
// new users are not enabled by default.
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$user = get_entity($user_guid);
if (!$user || !elgg_set_user_validation_status($user_guid, true, 'email')) {
    register_error(elgg_echo('email:confirm:fail'));
    forward();
}
system_message(elgg_echo('email:confirm:success'));
elgg_push_context('uservalidationbyemail_validate_user');
$user->enable();
elgg_pop_context();
try {
    login($user);
} catch (LoginException $e) {
    register_error($e->getMessage());
}
access_show_hidden_entities($access_status);
forward();
예제 #11
0
/**
 * Can we allow the user with the credentials to log in?
 * Check stormpath, create the user if they can log in and don't exist
 * Enable the user if they can log in but were waiting for email verification
 * 
 * @param type $credentials
 * @return boolean
 */
function pam_handler($credentials)
{
    // try to authenticate first
    $application = get_application();
    $authResult = $application->authenticate($credentials['username'], $credentials['password']);
    $account = $authResult->account;
    if (!$account || strtolower($account->status) != 'enabled') {
        return false;
    }
    // we need to search hidden users too
    // in case of email confirmation disabling
    $show_hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // we have an account and it's enabled
    // see if we have a matching account here
    // check if logging in with email address
    if (strpos($credentials['username'], '@') !== false) {
        $users = get_user_by_email($credentials['username']);
        $user = $users[0];
    } else {
        $user = get_user_by_username($credentials['username']);
    }
    // custom context gives us permission to do this
    elgg_push_context('stormpath_validate_user');
    // if we don't have a user we need to create one
    if (!$user) {
        $user = new \ElggUser();
        $user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
        $user->email = $account->email;
        $user->name = $account->fullName;
        $user->access_id = ACCESS_PUBLIC;
        $user->salt = _elgg_generate_password_salt();
        $user->password = generate_user_password($user, $credentials['password']);
        $user->owner_guid = 0;
        // Users aren't owned by anyone, even if they are admin created.
        $user->container_guid = 0;
        // Users aren't contained by anyone, even if they are admin created.
        $user->language = get_current_language();
        $user->save();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
        // Turn on email notifications by default
        set_user_notification_setting($user->getGUID(), 'email', true);
    }
    // see if we need to enable/verify the user
    if (!$user->isEnabled() && in_array($user->disable_reason, array('stormpath_new_user', 'uservalidationbyemail_new_user'))) {
        $user->enable();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
    }
    elgg_pop_context();
    access_show_hidden_entities($show_hidden);
    if ($user && $user->isEnabled()) {
        return true;
    }
    return false;
}
예제 #12
0
파일: start.php 프로젝트: enraiser/engap
function eg_reg_user($email, $password)
{
    //$ar=str_split("@",$email);
    $ar = explode("@", $email);
    $username = $ar[0];
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    if ($user = get_user_by_username($username)) {
        for ($tmp = 2; $tmp < 1000; $tmp++) {
            if (!($user = get_user_by_username($username . $tmp))) {
                $username .= $tmp;
                break;
            }
        }
    }
    access_show_hidden_entities($access_status);
    $ia = elgg_set_ignore_access(true);
    $guid1 = register_user($username, $password, $username, $email);
    elgg_set_user_validation_status($guid1, true, 'manual');
    elgg_set_ignore_access($ia);
    return $username;
}
예제 #13
0
파일: start.php 프로젝트: elgg/ldap_auth
/**
 * Create a new user from the data provided by LDAP
 *
 * @param string $username
 * @param string $password
 * @param array  $data Data fetched from LDAP
 */
function ldap_auth_create_user($username, $password, $data)
{
    // Check that we have the values. register_user() will take
    // care of more detailed validation.
    $firstname = elgg_extract('firstname', $data);
    $lastname = elgg_extract('lastname', $data);
    $email = elgg_extract('mail', $data);
    // Combine firstname and lastname
    $name = implode(' ', array($firstname, $lastname));
    try {
        $guid = register_user($username, $password, $name, $email);
    } catch (Exception $e) {
        register_error($e->getMessage());
        return false;
    }
    if (!$guid) {
        register_error(elgg_echo('ldap_auth:no_register'));
        elgg_log("Failed to create an account for LDAP user {$username}");
        return false;
    }
    $user = get_entity($guid);
    // Allow plugins to respond to the registration
    $params = array('user' => $user, 'ldap_entry' => $data);
    if (!elgg_trigger_plugin_hook('register', 'user', $params, true)) {
        // For some reason one of the plugins returned false.
        // This most likely means that something went wrong
        // and we will have to remove the user.
        $user->delete();
        register_error(elgg_echo('registerbad'));
        return false;
    }
    // Validate the user
    elgg_set_user_validation_status($guid, true, 'LDAP plugin based validation');
    return true;
}
예제 #14
0
/**
 * Register a user in Elgg based on information provided by the Service Provider (SP).
 *
 * @param string $name        the (display)name of the new user
 * @param string $email       the email address of the user
 * @param string $saml_source the name of the SP this information came from
 * @param bool   $validate    do we need to validate the email address of this new users
 * @param string $username    the username provided by the SP (optional)
 *
 * @return bool|ElggUser the new user, false on failure
 */
function simplesaml_register_user($name, $email, $saml_source, $validate = false, $username = "")
{
    $result = false;
    if (!empty($name) && !empty($email) && !empty($saml_source)) {
        // check which username to use
        if (!empty($username)) {
            // make sure the username is unique
            $username = simplesaml_generate_unique_username($username);
        } else {
            // create a username from email
            $username = simplesaml_generate_username_from_email($email);
        }
        if (!empty($username)) {
            // generate a random password
            $password = generate_random_cleartext_password();
            try {
                $user_guid = register_user($username, $password, $name, $email);
                if (!empty($user_guid)) {
                    $new_user = get_user($user_guid);
                    if (!$validate) {
                        // no need for extra validation. We trust this user
                        elgg_set_user_validation_status($new_user->getGUID(), true, "simplesaml");
                    }
                    $params = array("user" => $new_user, "password" => $password, "friend_guid" => null, "invitecode" => null);
                    if (!elgg_trigger_plugin_hook("register", "user", $params, true)) {
                        register_error(elgg_echo("registerbad"));
                    } else {
                        $result = $new_user;
                    }
                }
            } catch (Exception $e) {
                register_error($e->getMessage());
            }
        } else {
            register_error(elgg_echo("registration:usernamenotvalid"));
        }
    }
    return $result;
}
예제 #15
0
elgg_set_context($context);
// we have no local users, create a new one
$user = new \ElggUser();
$user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
$user->email = $account->email;
$user->name = $account->fullName;
$user->access_id = ACCESS_PUBLIC;
$user->salt = _elgg_generate_password_salt();
// set invalid PW that will never work for local login.  This can be changed by the user later
// but won't leave a secondary local login by accident
$user->password = _elgg_generate_password_salt();
$user->owner_guid = 0;
// Users aren't owned by anyone, even if they are admin created.
$user->container_guid = 0;
// Users aren't contained by anyone, even if they are admin created.
$user->language = get_current_language();
$user->save();
$user->__stormpath_user = $account->href;
elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
// Turn on email notifications by default
set_user_notification_setting($user->getGUID(), 'email', true);
// done with our extra permissions
elgg_pop_context();
login($user, true);
if ($user[0]->language) {
    $message = elgg_echo('loginok', array(), $user[0]->language);
} else {
    $message = elgg_echo('loginok');
}
system_message($message);
forward($login_forward);
예제 #16
0
$error = FALSE;
if (!$user_guids) {
    register_error(elgg_echo('uservalidationbyadmin:errors:unknown_users'));
    forward(REFERRER);
}
$access = access_get_show_hidden_status();
access_show_hidden_entities(TRUE);
foreach ($user_guids as $guid) {
    $user = get_entity($guid);
    if (!$user instanceof ElggUser) {
        $error = TRUE;
        continue;
    }
    // only validate if not validated
    $is_validated = elgg_get_user_validation_status($guid);
    $validate_success = elgg_set_user_validation_status($guid, TRUE, 'manual');
    if ($is_validated !== FALSE || !($validate_success && $user->enable())) {
        $error = TRUE;
        continue;
    } else {
        $site = elgg_get_site_entity();
        $subject = elgg_echo('user:validate:subject', array($user->name));
        $body = elgg_echo('user:validate:body', array($user->name, $site->name, $user->username, $user->name, $site->name, $user->username, $site->name, $site->url));
        $result = notify_user($user->guid, $site->guid, $subject, $body, NULL, 'email');
    }
}
access_show_hidden_entities($access);
if (count($user_guids) == 1) {
    $message_txt = elgg_echo('uservalidationbyadmin:messages:validated_user');
    $error_txt = elgg_echo('uservalidationbyadmin:errors:could_not_validate_user');
} else {
예제 #17
0
 /**
  * Create a new user or update an existing user from record
  *
  * @param array $record User record
  * @return array User record with status report
  */
 function uploadUser($record)
 {
     if (!$record['guid']) {
         // No user, try registering
         try {
             if (!$record['password']) {
                 $record['password'] = generate_random_cleartext_password();
             }
             $record['guid'] = register_user($record['username'], $record['password'], $record['name'], $record['email']);
             $user = get_entity($record['guid']);
             elgg_set_user_validation_status($record['guid'], true, 'upload_users');
             $hook_params = $record;
             $hook_params['user'] = $user;
             if (!elgg_trigger_plugin_hook('register', 'user', $hook_params, TRUE)) {
                 $ia = elgg_set_ignore_access(true);
                 $user->delete();
                 elgg_set_ignore_access($ia);
                 throw new RegistrationException(elgg_echo('registerbad'));
             }
             if ($this->notification) {
                 $subject = elgg_echo('upload_users:email:subject', array(elgg_get_config('sitename')));
                 $custom_message = elgg_get_plugin_setting('custom_message', 'upload_users', '');
                 $message = elgg_echo('upload_users:email:message', array($record['name'], elgg_get_config('sitename'), $record['username'], $record['password'], elgg_get_site_url(), $custom_message));
                 notify_user($record['guid'], elgg_get_site_entity()->guid, $subject, $message);
             }
         } catch (RegistrationException $e) {
             $record['__upload_users_status'] = false;
             $record['__upload_users_messages'][] = $e->getMessage();
         }
     } else {
         $user = get_entity($record['guid']);
     }
     if (!elgg_instanceof($user, 'user')) {
         $record['__upload_users_status'] = false;
         return $record;
     }
     foreach ($record as $metadata_name => $metadata_value) {
         switch ($metadata_name) {
             case '__upload_users_status':
             case '__upload_users_messages':
             case 'guid':
             case 'username':
             case 'password':
             case 'name':
             case 'email':
                 continue;
                 break;
             default:
                 $metadata_value = trim($metadata_value);
                 $header = $this->getHeaderForMetadataName($metadata_name);
                 $hook_params = array('header' => $header, 'metadata_name' => $metadata_name, 'value' => $metadata_value, 'record' => $record, 'user' => $user);
                 $custom = array('messages' => array(), 'status' => false);
                 $custom = elgg_trigger_plugin_hook('header:custom_method', 'upload_users', $hook_params, $custom);
                 if (isset($custom['messages'])) {
                     if (is_array($custom['messages'])) {
                         $record['__upload_users_messages'] = array_merge($record['__upload_users_messages'], $custom['messages']);
                     } else {
                         if (!empty($custom['messages'])) {
                             $record['__upload_users_messages'][] = $custom['messages'];
                         }
                     }
                 }
                 if ($custom === true || $custom['status'] === true) {
                     if (isset($custom['value'])) {
                         $record[$metadata_name] = $metadata_value;
                     }
                     continue;
                 }
                 $access_id = $this->getHeaderAccess($header);
                 $value_type = $this->getHeaderValueType($header);
                 switch ($value_type) {
                     default:
                     case 'text':
                         // keep the value
                         break;
                     case 'tags':
                         $metadata_value = string_to_tag_array($metadata_value);
                         break;
                     case 'timestamp':
                         $metadata_value = strtotime($metadata_value);
                         break;
                 }
                 $md_report = array();
                 if (is_array($metadata_value)) {
                     foreach ($metadata_value as $value) {
                         $value = trim($value);
                         if (create_metadata($user->guid, $metadata_name, trim($value), '', $user->guid, $access_id, true)) {
                             $md_report[] = $value;
                         }
                     }
                 } else {
                     if (create_metadata($user->guid, $metadata_name, $metadata_value, '', $user->guid, $access_id)) {
                         $md_report[] = $metadata_value;
                     }
                 }
                 $metadata_value = implode(',', $md_report);
                 elgg_log("Upload users: creating {$metadata_name} with value {$metadata_value} (as {$value_type}) and access_id {$access_id} for user {$user->guid}");
                 $record[$metadata_name] = $metadata_value;
                 break;
         }
     }
     return $record;
 }
예제 #18
0
 $count = count($guids);
 $error_nouser = $error_canedit = $error = $success = $validated = 0;
 foreach ($guids as $guid) {
     $user = get_entity($guid);
     if (!elgg_instanceof($user, 'user')) {
         $error_nouser++;
         continue;
     }
     if (!$user->canEdit()) {
         $error_canedit++;
         continue;
     }
     if (elgg_get_user_validation_status($user->guid)) {
         $validated++;
     } else {
         if (elgg_set_user_validation_status($user->guid, true, 'manual')) {
             create_annotation($user->guid, 'validate', true, '', elgg_get_logged_in_user_guid(), ACCESS_PUBLIC);
             $success++;
         } else {
             $error++;
         }
     }
 }
 $msg[] = elgg_echo('db_explorer:success:validate', array((int) $success, $count));
 if ($validated > 0) {
     $msg[] = elgg_echo('db_explorer:error:already_validated', array($validated));
 }
 if ($error_nouser > 0) {
     $msg[] = elgg_echo('db_explorer:error:nouser', array($error_nouser));
 }
 if ($error_canedit > 0) {
예제 #19
0
/**
 * Register a user in Elgg based on information provided by the Service Provider (SP).
 *
 * @param string $name        the (display)name of the new user
 * @param string $email       the email address of the user
 * @param string $saml_source the name of the SP this information came from
 * @param bool   $validate    do we need to validate the email address of this new users
 * @param string $username    the username provided by the SP (optional)
 *
 * @return false|ElggUser
 */
function simplesaml_register_user($name, $email, $saml_source, $validate = false, $username = '')
{
    if (empty($name) || empty($email) || empty($saml_source)) {
        return false;
    }
    // check which username to use
    if (!empty($username)) {
        // make sure the username is unique
        $username = simplesaml_generate_unique_username($username);
    } else {
        // create a username from email
        $username = simplesaml_generate_username_from_email($email);
    }
    if (empty($username)) {
        register_error(elgg_echo("registration:usernamenotvalid"));
        return false;
    }
    // generate a random password
    $password = generate_random_cleartext_password();
    try {
        $user_guid = register_user($username, $password, $name, $email);
        if (empty($user_guid)) {
            return false;
        }
        $new_user = get_user($user_guid);
        if (!$validate) {
            // no need for extra validation. We trust this user
            elgg_set_user_validation_status($new_user->getGUID(), true, 'simplesaml');
        }
        $params = ['user' => $new_user, 'password' => $password, 'friend_guid' => null, 'invitecode' => null];
        if (!elgg_trigger_plugin_hook('register', 'user', $params, true)) {
            register_error(elgg_echo('registerbad'));
        } else {
            return $new_user;
        }
    } catch (Exception $e) {
        register_error($e->getMessage());
    }
    return false;
}
예제 #20
0
/**
 * Set the validation status for a user.
 *
 * @param bool   $status Validated (true) or false
 * @param string $method Optional method to say how a user was validated
 * @return bool
 * @deprecated 1.8 Use elgg_set_user_validation_status()
 */
function set_user_validation_status($user_guid, $status, $method = '')
{
    elgg_deprecated_notice("set_user_validation_status() is deprecated", 1.8);
    return elgg_set_user_validation_status($user_guid, $status, $method);
}
예제 #21
0
     $username = subsite_manager_create_username_from_email($email);
 }
 // get password
 if (in_array("password", $columns)) {
     $col = array_search("password", $columns);
     $password = $data[$col];
 } else {
     $password = generate_random_cleartext_password();
 }
 if (!empty($username) && !empty($email) && !empty($displayname) && !empty($password)) {
     try {
         if ($user_guid = register_user($username, $password, $displayname, $email)) {
             $users_created++;
             $user = get_user($user_guid);
             // validate user
             elgg_set_user_validation_status($user->getGUID(), true, "email");
             // add user to subsite
             if (subsite_manager_on_subsite()) {
                 if (!$site->isUser($user->getGUID())) {
                     $site->addUser($user->getGUID());
                 }
             }
             // add metadata
             foreach ($columns as $col_id => $metadata_name) {
                 if (!in_array($metadata_name, array("username", "displayname", "email", "password"))) {
                     if ($profile_fields[$metadata_name] == "tags") {
                         $value = string_to_tag_array($data[$col_id]);
                     } else {
                         $value = $data[$col_id];
                     }
                     if (!empty($value)) {