Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I am trying to customize my email registration to take only email address when logging in, however the given API hook hook_email_registration_name does not load from my theme.
The code I have used is
/*
* Implements hook_email_registration_name().
* my theme name : mybartik
*/
function mybartik_email_registration_name($edit, $account) {
print_r('This should show up');
return $account->mail;
}
however the print_r statement never shows up.
Thanks for your help,
Perry.
ps: I was using the snippet from this post: http://grasmash.com/article/using-your-email-address-your-drupal-username
Comments
Comment #1
mbelos CreditAttribution: mbelos commentedHi,
All hook_* functions need to go in a module, not into a theme. It's not very clear, but it also says this in the link you posted:
Try creating a module (http://drupal.org/node/361112) and putting this function inside of it. Don't forget to install your module :)
Cheers,
mbelos
Comment #2
prabhatjn CreditAttribution: prabhatjn commentedHi,
I am not sure it still works...
I basically used the code in my module:
Also attached is the module that I have used.
I am not getting even a print_r statement.
Comment #3
mbelos CreditAttribution: mbelos commentedHmm, did you enable your module in /admin/modules? Also try putting an exit() in there to make sure it all works ok:
...or I like to use drupal_set_message():
Comment #4
profelm CreditAttribution: profelm commentedI've tried to do this with my own custom module.
The following function does not work:
Comment #5
andypostDo you enable module and clear a cache with a key '%implementation%'
Comment #6
profelm CreditAttribution: profelm commentedHi Andy,
I'm not quite sure what you mean by using that key. Can you please elaborate?
Comment #7
andypostI mean that it always works, so try to clean-up cache -
delete from cache_bootstrap where cid='module_implements'
Comment #8
cferthorneyForgive me if I need to file this as a separate issue (It's related to this one so I thought this was the best place to put it) The hook_email_registration_name seems to work fine for me from user-register-form when on the user/register page but not admin/people/create (A key component for the site I am working on) I have tried clearing the cache_bootstrap table and also 'drush cc all' (Which should do the same thing)
The error is quite a graceful one - it simply returns you to the /admin/people/list page with the "Add user" link replaced with text saying 'This web page allows administrators to register new users. Users' e-mail addresses and usernames must be unique.'
Our user registration settings are Anyone can register but admin approval is required and (Due to user_registrationpassword module)
Require a verification e-mail, but wait for the approval e-mail to let users set their password.
I have checked that the api hook within email_registration module doesn't function with user_registrationpassword off, as well as password_policy and one_time_login (The only other password related modules turned on on the site) and these do not seem to make the hook work.
Comment #9
gregglesAttached is a minimal module for 7.x that shows that this hook does indeed work, so I'm marking this issue as a fixed support request.
@cferthorney - I'm not sure I understand the problem you're describing. If you still need help it does seem pretty different than the thrust of this issue and should therefore go in a new one. Sorry it's not working as you expect :(