Skip to content

Instantly share code, notes, and snippets.

function _apci_api_user_create($firstname, $lastname, $email, $gender, $birthday, $password = NULL) {
$account = array(
'mail' => $email,
'field_firstname' => array(array('value' => $firstname)),
'field_lastname' => array(array('value' => $lastname)),
'field_user_gender' => array(array('value' => (strtolower($gender) == 'm') ? 1 : 2)),
'field_birth_date' => array(array('value' => array(
'month' => $birthday['month'],
'hour' => '0',
'minute' => '0',
<?php
/**
* @file
* Allows users of a particular role to create sub user account in another role.
*
* Copyright 2008-2009 by Jimmy Berry ("boombatower", http://drupal.org/user/214218)
*/
/*
* Variables loaded as constants.
Processing DoclistController#documents (for 38.107.251.3 at 2011-09-30 10:13:14) [GET]
Parameters: {"token"=>"1/SyL9HODSJF6v5v6rYCDd_II1m988F4W5DblEYvbIKfg"}
GData::Client::AuthorizationError (request error 403: <errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>ServiceForbiddenException</code><internalReason>403.4 SSL required</internalReason></error></errors>):
gdata (1.1.2) lib/gdata/client/base.rb:87:in `make_request'
gdata (1.1.2) lib/gdata/client/base.rb:103:in `get'
app/controllers/doclist_controller.rb:239:in `set_user_email'
passenger (3.0.9) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.9) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.9) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
Do you wish to run all pending updates? (y/n): y
The external command could not be executed due to an application error. [error]
Executing apci_user_update_6003 [success]
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Cannot redeclare drupal_mail_wrapper() (previously declared in /home/ubuntu/apci/www/sites/all/modules/contrib/smtp/smtp.module:860) in
/home/ubuntu/apci/www/sites/all/modules/contrib/devel/devel.module, line 1913
Output from failed command : [error]
Fatal error: Cannot redeclare drupal_mail_wrapper() (previously declared in /home/ubuntu/apci/www/sites/all/modules/contrib/smtp/smtp.modu
/**
* Make sure that we have no duplicate emails on user creation by updating schema for mail field in users table.
*/
function apci_user_update_6003() {
$ret = array();
$unique_mail = array();
$duplicates = db_query('SELECT DISTINCT a.uid, a.mail, a.name FROM users a INNER JOIN users b ON a.mail = b.mail WHERE a.uid <> b.uid ORDER BY a.uid');
while($duplicate = db_fetch_object($duplicates)) {
if(array_key_exists(strtolower($duplicate->mail), $unique_mail)) {
list($mail_1, $mail_2) = split('@', $duplicate->mail);