Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
email_registration
Commits
e312abf0
Commit
e312abf0
authored
Oct 11, 2007
by
Chris Herberte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial upload
parents
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
email_registration.info
email_registration.info
+3
-0
email_registration.module
email_registration.module
+69
-0
No files found.
email_registration.info
0 → 100644
View file @
e312abf0
; $Id$
name = Email Registration
description = "For registration process without a username."
email_registration.module
0 → 100644
View file @
e312abf0
<?php
// $Id$
/**
* Implementation of hook_user().
*
*/
function
email_registration_user
(
$op
,
&
$edit
,
&
$account
,
$category
=
NULL
)
{
switch
(
$op
)
{
case
'insert'
:
$newname
=
preg_replace
(
'/@.*$/'
,
''
,
$edit
[
'mail'
]);
if
(
db_num_rows
(
db_query
(
"SELECT uid FROM
{
users
}
WHERE uid != %d AND LOWER(name) = LOWER('%s')"
,
$account
->
uid
,
$newname
))
>
0
)
{
// may need to fix this if dupe random names are created. although not lkely, still there's no error checking
$newname
.
=
rand
(
100
,
999
);
}
db_query
(
"UPDATE
{
users
}
SET name = '%s' WHERE uid = '%s'"
,
$newname
,
$account
->
uid
);
break
;
}
return
;
}
/**
* Implementation of hook_form_alter().
*
*/
function
email_registration_form_alter
(
$form_id
,
&
$form
)
{
switch
(
$form_id
)
{
case
'user_register'
:
$form
[
'name'
][
'#type'
]
=
'hidden'
;
$form
[
'name'
][
'#value'
]
=
user_password
();
$form
[
'mail'
][
'#title'
]
=
t
(
'E-mail'
);
break
;
case
'user_pass'
:
$form
[
'name'
][
'#title'
]
=
t
(
'E-mail'
);
$form
[
'name'
][
'#description'
]
=
t
(
'Enter your e-mail address. You\'ll be sent a new password immediately.'
);
break
;
case
'user_login'
:
$form
[
'name'
][
'#title'
]
=
t
(
'E-mail'
);
$form
[
'name'
][
'#description'
]
=
'Enter your e-mail address.'
;
$form
[
'#validate'
]
=
array
(
'email_registration_user_login_validate'
=>
array
())
+
$form
[
'#validate'
];
break
;
case
'user_login_block'
:
$form
[
'name'
][
'#title'
]
=
t
(
'E-mail'
);
$form
[
'#validate'
]
=
array
(
'email_registration_user_login_validate'
=>
array
())
+
$form
[
'#validate'
];
break
;
}
}
/**
* Custom validation function for user login form.
* Allows users to authenticate by email only, which is our preferred method.
*
*/
function
email_registration_user_login_validate
(
$form_id
,
$form_values
,
$form
)
{
if
(
isset
(
$form_values
[
'name'
]))
{
if
(
$name
=
db_result
(
db_query
(
"SELECT name FROM
{
users
}
WHERE LOWER(mail) = LOWER('%s')"
,
$form_values
[
'name'
])))
{
form_set_value
(
$form
[
'name'
],
$name
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment