本文整理汇总了PHP中user_load_by_mail函数的典型用法代码示例。如果您正苦于以下问题:PHP user_load_by_mail函数的具体用法?PHP user_load_by_mail怎么用?PHP user_load_by_mail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_load_by_mail函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: authenticate
public function authenticate(&$message, $mailbox)
{
$uid = 0;
// Check and parse messageid for parameters. URL will be encoded.
$force_user_lookup = FALSE;
$identifier = _mailcomment_get_signature(rawurldecode($message['body_html']));
// Failed to find signature in body -- replicate mailhandler functionality to find node->threading
if (!$identifier) {
if (!empty($message['header']->references)) {
// we want the final element in references header, watching out for white space
$identifier = drupal_substr(strrchr($message['header']->references, '<'), 0);
} elseif (!empty($message['header']->in_reply_to)) {
// Some MUAs send more info in this header.
$identifier = str_replace(strstr($message['header']->in_reply_to, '>'), '>', $message['header']->in_reply_to);
}
if (isset($identifier)) {
$identifier = rtrim(ltrim($identifier, '<'), '>');
$force_user_lookup = TRUE;
}
}
$params = mailcomment_check_messageparams($identifier);
if ($force_user_lookup) {
// get uid from email address because we are using the header information to load the params
// these contain the uid of the person who's post you are responding to
$sender = $message['header']->from[0]->mailbox . '@' . $message['header']->from[0]->host;
$params['uid'] = user_load_by_mail($sender)->uid;
}
if ($params['uid']) {
$account = user_load($params['uid']);
$uid = $account->uid;
}
return $uid;
}
开发者ID:Chaogan-Yan,项目名称:rfmri.org,代码行数:33,代码来源:MailcommentAuthenticate.class.php
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$values = $form_state->getValues();
$file = File::load($values['file'][0]);
// Load File entity.
$read_file = new \SplFileObject($file->url());
// Create file handler.
$lines = 1;
$in_queue = 0;
$queue = \Drupal::queue('eventninja');
// Load queue
while (!$read_file->eof()) {
$data = $read_file->fgetcsv(';');
if ($lines > 1) {
// skip headers
$user = user_load_by_mail($data[1]);
if ($user === false) {
// Verify if user with specified email does not exist.
$queue->createItem($data);
$in_queue++;
} else {
$this->logger('eventninja')->log(RfcLogLevel::NOTICE, 'User {mail} hasn\'t been created.', ['mail' => $data[1]]);
}
}
$lines++;
}
if ($lines > 1) {
drupal_set_message($this->t('@num records was scheduled for import', array('@num' => $in_queue)), 'success');
} else {
drupal_set_message($this->t('File contains only headers'), 'error');
}
}
开发者ID:slovak-drupal-association,项目名称:dccs,代码行数:35,代码来源:AdminForm.php
示例3: hook_mandrill_mailsend_result
/**
* Allow other modules to respond to the result of sending an email.
*
* @param array $result
* Associative array containing the send result, including the status.
*/
function hook_mandrill_mailsend_result($result)
{
if ($result['status'] == 'rejected') {
// Delete user.
$user = user_load_by_mail($result['email']);
user_delete($user->uid);
}
}
开发者ID:isaenkov,项目名称:Dru.io,代码行数:14,代码来源:mandrill.api.php
示例4: authenticate
public function authenticate(&$message, $mailbox)
{
list($fromaddress, $fromname) = _mailhandler_get_fromaddress($message['header'], $mailbox);
$uid = 0;
if ($from_user = user_load_by_mail($fromaddress)) {
$uid = $from_user->uid;
}
return $uid;
}
开发者ID:redponey,项目名称:openatrium-7.x-2.51,代码行数:9,代码来源:MailhandlerAuthenticateDefault.class.php
示例5: authenticate
/**
* Implements authenticate().
*/
public function authenticate(&$message, $mailbox)
{
list($fromaddress, ) = _mailhandler_get_fromaddress($message['header'], $mailbox);
$uid = 0;
// If user with given email address exists and their token is in the toaddress, allow.
if (($from_user = user_load_by_mail($fromaddress)) && strpos($header->to[0]->mailbox, tokenauth_get_token($from_user->uid)) !== FALSE) {
$uid = $from_user->uid;
}
return $uid;
}
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:13,代码来源:MailhandlerAuthenticateTokenauth.class.php
示例6: postReset
public function postReset()
{
$drupal = new \erdiko\drupal\models\User();
$account = \user_load_by_mail($_POST['mail']);
$edit = array();
if ($_POST['pass']['pass1'] == $_POST['pass']['pass2']) {
$edit['pass'] = $_POST['pass']['pass1'];
\user_save($account, $edit);
$this->setContent('Your password was successfully changed.');
} else {
$this->setContent('The password and confirmation password do not match.');
}
}
开发者ID:saarmstrong,项目名称:erdiko-drupal,代码行数:13,代码来源:Password.php
示例7: processItem
/**
* {@inheritdoc}
*/
public function processItem($data)
{
if (FALSE === user_load_by_mail($data->attendee->email)) {
try {
// build array of user data
$user_data = ['mail' => $data->attendee->email, 'name' => $data->attendee->email, 'status' => 1, 'field_first_name' => ['value' => $data->attendee->first_name], 'field_last_name' => ['value' => $data->attendee->last_name]];
// create User entity
$user = entity_create('user', $user_data);
$user->save();
// notify user about new account
_user_mail_notify('register_admin_created', $user);
// create user profile
$this->createUserProfile($user);
} catch (\Exception $e) {
\Drupal::logger('eventbrite')->log(RfcLogLevel::ERROR, 'User {mail} hasn\'t been created.', ['mail' => $data->attendee->email]);
}
}
}
开发者ID:slovak-drupal-association,项目名称:dccs,代码行数:21,代码来源:EventbriteSync.php
示例8: wyc_add_user
function wyc_add_user($user_data)
{
$joined = ($date = strtotime($user_data['JoinDate'])) && $date != false ? $date : null;
$expires = ($date = strtotime($user_data['d_membership_expires'])) && $date != false ? date('Y-m-d H:i:s', $date) : null;
$mail = strpos($user_data['Email'], '@') === false ? $user_data['WYCNumber'] . '@wyc_intranet.com' : $user_data['Email'];
//set up the user fields
$fields = array('name' => $user_data['WYCNumber'], 'mail' => $mail, 'pass' => user_password(8), 'status' => 1, 'init' => 'email address', 'roles' => array(DRUPAL_AUTHENTICATED_RID => 'authenticated user'), 'field_full_name' => array(LANGUAGE_NONE => array(array('value' => $user_data['First'] . ' ' . $user_data['Last']))), 'field_wyc_number' => array(LANGUAGE_NONE => array(array('value' => $user_data['WYCNumber']))), 'field_phone_number' => array(LANGUAGE_NONE => array(array('value' => $user_data['Phone1']), array('value' => $user_data['Phone2']))), 'field_address' => array(LANGUAGE_NONE => array(array('thoroughfare' => $user_data['StreetAddress'], 'locality' => $user_data['City'], 'administrative_area' => $user_data['State'], 'postal_code' => $user_data['ZipCode']))), 'field_membership_expires' => array(LANGUAGE_NONE => array(array('value' => $expires))), 'created' => date('U', $joined));
$old = user_load_by_mail($mail);
if (empty($old->uid)) {
$new = user_save('', $fields);
wyc_log('wyc_user_created', $user_data);
if (empty($new->uid)) {
wyc_log('wyc_user_create_failed', $user_data);
}
} else {
wyc_log('wyc_user_create_skipped', $user_data);
}
}
开发者ID:sodacrackers,项目名称:washyacht,代码行数:18,代码来源:wyc_drush_users.php
示例9: completeSaleAccount
/**
* {@inheritdoc}
*/
public function completeSaleAccount($order)
{
// Order already has a user ID, so the user was logged in during checkout.
if ($order->getUserId()) {
$order->data->complete_sale = 'logged_in';
return;
}
// Email address matches an existing account.
if ($account = user_load_by_mail($order->getEmail())) {
$order->setUserId($account->id());
$order->data->complete_sale = 'existing_user';
return;
}
// Set up a new user.
$cart_config = $this->config('uc_cart.settings');
$fields = array('name' => uc_store_email_to_username($order->getEmail()), 'mail' => $order->getEmail(), 'init' => $order->getEmail(), 'pass' => user_password(), 'roles' => array(), 'status' => $cart_config->get('new_customer_status_active') ? 1 : 0);
// Override the username, if specified.
if (isset($order->data->new_user_name)) {
$fields['name'] = $order->data->new_user_name;
}
// Create the account.
$account = \Drupal\user\Entity\User::create($fields);
$account->save();
// Override the password, if specified.
if (isset($order->data->new_user_hash)) {
db_query('UPDATE {users_field_data} SET pass = :hash WHERE uid = :uid', [':hash' => $order->data->new_user_hash, ':uid' => $account->id()]);
$account->password = t('Your password');
} else {
$account->password = $fields['pass'];
$order->password = $fields['pass'];
}
// Send the customer their account details if enabled.
if ($cart_config->get('new_customer_email')) {
$type = $cart_config->get('new_customer_status_active') ? 'register_no_approval_required' : 'register_pending_approval';
\Drupal::service('plugin.manager.mail')->mail('user', $type, $order->getEmail(), uc_store_mail_recipient_langcode($order->getEmail()), array('account' => $account), uc_store_email_from());
}
$order->setUserId($account->id());
$order->data->new_user_name = $fields['name'];
$order->data->complete_sale = 'new_user';
}
开发者ID:pedrocones,项目名称:hydrotools,代码行数:43,代码来源:Cart.php
示例10: brukar_client_login
function brukar_client_login($data)
{
global $user;
$edit = array('name' => t(variable_get('brukar_name', '!name'), array('!name' => $data['name'], '!sident' => substr($data['id'], 0, 4), '!ident' => $data['id'])), 'mail' => $data['mail'], 'status' => 1, 'data' => array('brukar' => $data));
if ($user->uid != 0) {
user_save($user, $edit);
user_set_authmaps($user, array('authname_brukar' => $data['id']));
drupal_goto('user');
}
$authmap_user = db_query('SELECT uid FROM {authmap} WHERE module = :module AND authname = :ident', array(':ident' => $data['id'], ':module' => 'brukar'))->fetch();
if ($authmap_user === FALSE) {
$provided = module_invoke_all('brukar_client_user', $edit);
$user = !empty($provided) ? $provided[0] : user_save(user_load_by_mail($data['mail']), $edit);
user_set_authmaps($user, array('authname_brukar' => $data['id']));
} else {
$user = user_save(user_load($authmap_user->uid), $edit);
}
$form_state = (array) $user;
user_login_submit(array(), $form_state);
// Better solution available?
$query = $_GET;
unset($query['q']);
drupal_goto($_GET['q'] == variable_get('site_frontpage') ? '<front>' : url($_GET['q'], array('absolute' => TRUE, 'query' => $query)));
}
开发者ID:evenos,项目名称:drupal7-module-brukar,代码行数:24,代码来源:brukar_client.oauth.php
示例11: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$operation = $input->getArgument('operation');
$user = $input->getArgument('user');
$role = $input->getArgument('role');
$systemRoles = $this->drupalApi->getRoles();
if (is_numeric($user)) {
$userObject = user_load($user);
} else {
$userObject = user_load_by_name($user);
}
if (!is_object($userObject)) {
if (!filter_var($user, FILTER_VALIDATE_EMAIL) === false) {
$userObject = user_load_by_mail($user);
}
}
if (!is_object($userObject)) {
$io->error(sprintf($this->trans('commands.user.role.messages.no-user-found'), $user));
return 1;
}
if (!array_key_exists($role, $systemRoles)) {
$io->error(sprintf($this->trans('commands.user.role.messages.no-role-found'), $role));
return 1;
}
if ("add" == $operation) {
$userObject->addRole($role);
$userObject->save();
$io->success(sprintf($this->trans('commands.user.role.messages.add-success'), $userObject->name->value . " (" . $userObject->mail->value . ") ", $role));
}
if ("remove" == $operation) {
$userObject->removeRole($role);
$userObject->save();
$io->success(sprintf($this->trans('commands.user.role.messages.remove-success'), $userObject->name->value . " (" . $userObject->mail->value . ") ", $role));
}
}
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:39,代码来源:RoleCommand.php
示例12: getUser
/**
* {@inheritdoc}
*/
public function getUser()
{
$mail = $this->getMail();
if (empty($mail)) {
return NULL;
}
if ($user = User::load($this->getUserId())) {
return $user;
} else {
return user_load_by_mail($this->getMail()) ?: NULL;
}
}
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:15,代码来源:Subscriber.php
示例13: getUserDetails
public function getUserDetails($username)
{
$account = user_load_by_name($username);
if (!$account) {
// An email address might have been supplied instead of the username.
$account = user_load_by_mail($username);
}
if ($account) {
return array('user_id' => $account->uid);
}
return FALSE;
}
开发者ID:casivaagustin,项目名称:drupal-services,代码行数:12,代码来源:Storage.php
示例14: createRandom
/**
* Create new users with default field values.
*
* @param int $num
* Number of entities to create.
* @param array $options
* Options array. This array can have "roles" key that provides an array of
* role names that the newly created user will need to be assigned.
*
* @return Response
* Response object.
*/
public static function createRandom($num = 1, $options = array())
{
if (!is_numeric($num)) {
return new Response(FALSE, NULL, 'Number of users to be created has to be an integer.');
}
$options += array('roles' => array(), 'required_fields_only' => TRUE);
// First get the references that need to be created.
//static::processBeforeCreateRandom($options);
$output = array();
for ($i = 0; $i < $num; $i++) {
// Get a random username.
do {
$username = Utils::getRandomString(20);
} while (!is_null(user_validate_name($username)) || user_load_by_name($username));
// Get a random email address.
do {
$email = $username . '@' . Utils::getRandomString(20) . '.com';
} while (!is_null(user_validate_mail($email)) || user_load_by_mail($email));
// Get a random password.
$password = Utils::getRandomString();
$response = User::registerUser($username, $email, $password, $options);
if (!$response->getSuccess()) {
$response->setVar($output);
return $response;
}
$output[] = $response->getVar();
}
return new Response(TRUE, Utils::normalize($output), "");
}
开发者ID:redcrackle,项目名称:redtest-core,代码行数:41,代码来源:User.php
示例15: subscribe
/**
* {@inheritdoc}
*/
public function subscribe($mail, $newsletter_id, $confirm = NULL, $source = 'unknown', $preferred_langcode = NULL)
{
// Get current subscriptions if any.
$subscriber = simplenews_subscriber_load_by_mail($mail);
// If user is not subscribed to ANY newsletter, create a subscription account
if (!$subscriber) {
// To subscribe a user:
// - Fetch the users uid.
// - Determine the user preferred language.
// - Add the user to the database.
// - Get the full subscription object based on the mail address.
// Note that step 3 gets subscription data based on mail address because the uid can be 0 (for anonymous users)
$account = user_load_by_mail($mail);
// If the site is multilingual:
// - Anonymous users are subscribed with their preferred language
// equal to the language of the current page.
// - Registered users will be subscribed with their default language as
// set in their account settings.
// By default the preferred language is not set.
if ($this->languageManager->isMultilingual()) {
if ($account) {
$preferred_langcode = $account->getPreferredLangcode();
} else {
$preferred_langcode = isset($preferred_langcode) ? $preferred_langcode : $this->languageManager->getCurrentLanguage();
}
} else {
$preferred_langcode = '';
}
$subscriber = Subscriber::create(array());
$subscriber->setMail($mail);
if ($account) {
$subscriber->setUserId($account->id());
}
$subscriber->setLangcode($preferred_langcode);
$subscriber->setStatus(SubscriberInterface::ACTIVE);
$subscriber->save();
}
$newsletter = simplenews_newsletter_load($newsletter_id);
// If confirmation is not explicitly specified, use the newsletter
// configuration.
if ($confirm === NULL) {
$confirm = $this->requiresConfirmation($newsletter, $subscriber->getUserId());
}
if ($confirm) {
// Create an unconfirmed subscription object if it doesn't exist yet.
if (!$subscriber->isSubscribed($newsletter_id)) {
$subscriber->subscribe($newsletter_id, SIMPLENEWS_SUBSCRIPTION_STATUS_UNCONFIRMED, $source);
$subscriber->save();
}
$this->addConfirmation('subscribe', $subscriber, $newsletter);
} elseif (!$subscriber->isSubscribed($newsletter_id)) {
// Subscribe the user if not already subscribed.
$subscriber->subscribe($newsletter_id, SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED, $source);
$subscriber->save();
}
return $this;
}
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:60,代码来源:SubscriptionManager.php
示例16: getCredentials
/**
* @param Request $request
* @return JsonResponse
*/
public function getCredentials(Request $request)
{
$data = json_decode($request->getContent(), TRUE);
$fields = array('time' => 'is_numeric', 'nonce' => 'is_string', 'hash' => 'is_string');
$result = $this->basicAuthenticator($fields, $data);
if (!empty($result['error'])) {
return new JsonResponse($result, self::ACQTEST_SUBSCRIPTION_SERVICE_UNAVAILABLE);
}
if (!empty($data['body']['email'])) {
$account = user_load_by_mail($data['body']['email']);
\Drupal::logger('getCredentials password')->debug($account->getPassword());
if (empty($account) || $account->isAnonymous()) {
return new JsonResponse($this->errorResponse(self::ACQTEST_SUBSCRIPTION_VALIDATION_ERROR, t('Account not found')), self::ACQTEST_SUBSCRIPTION_SERVICE_UNAVAILABLE);
}
} else {
return new JsonResponse($this->errorResponse(self::ACQTEST_SUBSCRIPTION_VALIDATION_ERROR, t('Invalid arguments')), self::ACQTEST_SUBSCRIPTION_SERVICE_UNAVAILABLE);
}
$hash = CryptConnector::acquiaHash($account->getPassword(), $data['authenticator']['time'] . ':' . $data['authenticator']['nonce']);
if ($hash === $data['authenticator']['hash']) {
$result = array();
$result['is_error'] = FALSE;
$result['body']['subscription'][] = array('identifier' => self::ACQTEST_ID, 'key' => self::ACQTEST_KEY, 'name' => self::ACQTEST_ID);
return new JsonResponse($result);
} else {
return new JsonResponse($this->errorResponse(self::ACQTEST_SUBSCRIPTION_VALIDATION_ERROR, t('Incorrect password.')), self::ACQTEST_SUBSCRIPTION_SERVICE_UNAVAILABLE);
}
}
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:31,代码来源:NspiController.php
示例17: load_by_mail
/**
* Attempt to load a user account.
*
* @param string $mail
* @return mixed
*/
public function load_by_mail($mail)
{
return user_load_by_mail($mail);
}
开发者ID:bjargud,项目名称:drush,代码行数:10,代码来源:UserVersion.php
示例18: emailPopupSubmit
public function emailPopupSubmit()
{
if (isset($_SESSION['lrdata']) && !empty($_SESSION['lrdata'])) {
$userprofile = $_SESSION['lrdata'];
$userprofile->Email_value = trim($_POST['email']);
if (!\Drupal::service('email.validator')->isValid($userprofile->Email_value)) {
$popup_params = array('msg' => t('This email is invalid. Please choose another one.'), 'provider' => $userprofile->Provider, 'msgtype' => 'warning');
$popup_params['message_title'] = $this->module_config->get('popup_title');
return $form['email_popup'] = $this->getPopupForm($popup_params);
} else {
$check_mail = user_load_by_mail($userprofile->Email_value);
if (!empty($check_mail)) {
$email_wrong = $this->module_config->get('popup_error');
$popup_params = array('msg' => t($email_wrong), 'provider' => $userprofile->Provider, 'msgtype' => 'warning');
$popup_params['message_title'] = $this->module_config->get('popup_title');
return $form['email_popup'] = $this->getPopupForm($popup_params);
} else {
unset($_SESSION['lrdata']);
$_SESSION['user_verify'] = 1;
return $this->createUser($userprofile);
}
}
}
return new RedirectResponse(Url::fromRoute('<current>')->toString());
}
开发者ID:LoginRadius,项目名称:drupal-identity-module,代码行数:25,代码来源:SocialLoginUserManager.php
示例19: loadByEmail
/**
* @param string $email
*
* @return static
*
* @throws InvalidArgumentException
*/
public static function loadByEmail($email)
{
$account = user_load_by_mail($email);
if ($account) {
return new static($account);
}
throw new InvalidArgumentException(t('Unable to load user with email %email', ['%email' => $email]));
}
开发者ID:jall,项目名称:entity_wrappers,代码行数:15,代码来源:User.php
示例20: createRandom
/**
* Create new users with default field values.
*
* @param int $num
* Number of entities to create.
* @param array $options
* Options array. This array can have "roles" key that provides an array of
* role names that the newly created user will need to be assigned.
*
* @return Response
* Response object.
*/
public static function createRandom($num = 1, $options = array())
{
$options += array('roles' => array(), 'required_fields_only' => TRUE);
$output = array();
for ($i = 0; $i < $num; $i++) {
// Get a random username.
do {
$username = Utils::getRandomString(20);
} while (!is_null(user_validate_name($username)) || user_load_by_name($username));
// Get a random email address.
do {
$email = $username . '@' . Utils::getRandomString(20) . '.com';
} while (!is_null(user_validate_mail($email)) || user_load_by_mail($email));
// Get a random password.
$password = Utils::getRandomString();
$response = User::registerUser($username, $email, $password, $options['roles']);
if (!$response->getSuccess()) {
$response->setVar($output);
return $response;
}
$output[] = $response->getVar();
}
return new Response(TRUE, Utils::normalize($output), "");
}
开发者ID:vishalred,项目名称:redtest-core-pw,代码行数:36,代码来源:User.php
注:本文中的user_load_by_mail函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论