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

CommentFileSizeAuthor
#9 er.tgz330 bytesgreggles
#2 first.tar_.gz642 bytesprabhatjn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mbelos’s picture

Hi,

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:

Adding a similar snippet to your own custom module will give you complete control. That's all there is to it!

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

prabhatjn’s picture

FileSize
642 bytes

Hi,

I am not sure it still works...
I basically used the code in my module:

function first_email_registration_name($edit, $account) {
	dpm($account);
	print_r($account);
  return $account->mail;
}

Also attached is the module that I have used.
I am not getting even a print_r statement.

mbelos’s picture

Hmm, did you enable your module in /admin/modules? Also try putting an exit() in there to make sure it all works ok:

function first_email_registration_name($edit, $account) {
    dpm($account);
    print_r($account);
exit();
  return $account->mail;
}

...or I like to use drupal_set_message():

function first_email_registration_name($edit, $account) {
    dpm($account);
    drupal_set_message('<pre>' . print_r($account, true) . '</pre>');
  return $account->mail;
}
profelm’s picture

I've tried to do this with my own custom module.

The following function does not work:

<?php
function user_subscription_email_registration_name($edit, $account) {
    exit();
}
?>
andypost’s picture

Status: Active » Postponed (maintainer needs more info)

Do you enable module and clear a cache with a key '%implementation%'

profelm’s picture

Hi Andy,

I'm not quite sure what you mean by using that key. Can you please elaborate?

andypost’s picture

I mean that it always works, so try to clean-up cache - delete from cache_bootstrap where cid='module_implements'

cferthorney’s picture

Forgive 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.

greggles’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Fixed
FileSize
330 bytes

Attached 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 :(

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.