Currently an inactive user gets warnings about becoming inactive and then gets blocked without a mail about the action of getting blocked.

It would be nice to send them an email at the moment they are blocked so they know what happened.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles created an issue. See original summary.

bhavikshah9’s picture

Here is the patch for requested feature.

bhavikshah9’s picture

Status: Active » Needs review
greggles’s picture

Status: Needs review » Needs work

This all seems like an improvement. One thought:

+      if (user_save($account, array('status' => 0)) !== FALSE) {

Now that's inside an if, it seems good to have an "else" case that will log an error to watchdog and do a drupal_set_message. Can you provide that?

bhavikshah9’s picture

Sure.
Here is the updated patch with else case that log an error to watchdog and does a drupal_set_message.

bhavikshah9’s picture

Status: Needs work » Needs review
bhavikshah9’s picture

Can someone RTBC this?

greggles’s picture

Hi bhavikshah9, it would help rtbc if you could provide an automated test for this feature.

Any chance you have time to do that?

bhavikshah9’s picture

Hi greggles, Sure. Soon, I will provide new patch with automated test.

bhavikshah9’s picture

Here is the latest patch with automated test.

  1. Added couple of tests for verifying that account expiration notification emails are sent and sent to correct destination
  2. Rectified TestCase
  3. Pushed creating new accounts in setUp method instead of test method
bhavikshah9’s picture

Can someone RTBC this?

greggles’s picture

Status: Needs review » Needs work

I did a more thorough code-level review and found some items that seem ideal to fix.

Thanks for all your work so far. I think this is really close!

  1. +++ b/user_expire.module
    @@ -278,11 +278,21 @@ function user_expire_expire_users(array $accounts) {
    +        // User account has expired, status set to '0'
    

    Missing punctuation on the end of the line.

  2. +++ b/user_expire.module
    @@ -278,11 +278,21 @@ function user_expire_expire_users(array $accounts) {
    +        watchdog('user_expire', 'Cannot update status for User %name.', array('%name' => $account->name));
    

    I think it's more common to leave "User" lower case in the middle of the sentence. Also, the default watchdog severity level is a notice, but this seems more important than that. WATCHDOG_ERROR or WATCHDOG_CRITICAL seem more appropriate to me.

  3. +++ b/user_expire.module
    @@ -473,4 +483,19 @@ function user_expire_mail($key, &$message, $params) {
    +    $message['body'][] = t('We have written this email to inform you that, your account at @site_name is blocked.',
    

    I think the comma in this line is not grammatically correct. I suggest removing it.

  4. +++ b/user_expire.test
    @@ -4,29 +4,46 @@
    +    $this->assertTrue($this->basic_account->status, t('User account is currently enabled.'));
    

    Thanks for all the code cleanup and for adding tests for this new code!

bhavikshah9’s picture

Hi @greggles,
Thanks for re-viewing my code. I will apply those corrections and will submit new patch soon.

bhavikshah9’s picture

Here is the fresh patch with all the updates and suggested corrections.

bhavikshah9’s picture

Status: Needs work » Needs review

  • greggles committed 77ddd05 on 7.x-1.x authored by bhavikshah9
    Issue #2611890 by bhavikshah9: Mail users when their account is blocked
    
greggles’s picture

Status: Needs review » Fixed

Thanks for the work!

This is now committed.

Status: Fixed » Closed (fixed)

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