Resending Drupal Revalidation Links

On many of the Drupal-based sites I design I use a wonderful module called LoginToboggan, which provides a number of features related to user login. One such feature is the non-authenticated role, which is an interim role that a user can be set to after registering but before validating their email address.

Related to that feature is another that allows the non-authenticated user to have the validation message resent to them. Unfortunately, this feature is a bit buried, since it requires that the user (or an administrator) edit their account to reach the link to send the message. I decided to make the link a bit more visible.

I wanted a message to appear on every page, reminding the user to validate their account and providing the link to resend the validation email. The first step was to create a block with no title and assign it to a region—any region. The role-specific visibility setting was set to the non-authenticated role.

Then, using the PHP code input filter, I set the body of the block to this:

global $user;
  "Your account is unvalidated. Please check your email and click the validation link that was sent to you. ". 
    l(t('Resend validation e-mail'), 'toboggan/revalidate/'. $user-&gt;uid,
        'query' =&gt; drupal_get_destination()
    ) .'.',"warning",FALSE

This reminds the user and displays the LoginToboggan revalidation link for the current user, with the additional nice touch of overriding the module’s default behavior of returning to the user’s account edit page.