I am using the Private Message module on my site; users receive a notification by e-mail when they receive a new message.

In this e-mail, there is a link to the login page. Many users access the page via their mobile phones, so typing in their username can be a pain (they might also forget what their username is).

Is there some way to prepopulate the username via the link in the e-mail, perhaps using tokens?


2 Answers 2


You can do it using Prepopulate module. You haven't mentioned the version you are working with. It's in dev version for D7.

When you configure the email, use token in the same format given in the example to pass value of their username, which will be prepopulated when they click on your sent link.

  • 1
    Here's the token string I appended to the URL if anyone needs an example: ?edit[name]=[username_token] Aug 22, 2013 at 13:45
function YOURMODULE_form_user_login_block_alter(&$form, &$form_state, $form_id) {
    $form['name']['#default_value'] = $_GET['email'];

That'll grab the email from a URL query string and pre-fill the login form e.g.:

http://yoursite.com/[email protected]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.