0

I have a page that users rarely visit but I would like to send myself an e-mail to the effect of "UID 555 visited the special page."

My site has several hundred pages but I only want to send an e-mail for this specific page.

I thought of using rules (event: when content is viewed), but

  1. this event has to be evaluated on every page hit
  2. it doesn't seem to trigger when the page is embedded within a panel

So, I was wondering if there is some way to easily send myself an email with the UID whenever a user visits a specific panel page.

1

Add the code below to any of your module. I assumed the name of the module to be my_module.

define('MY_SPECIFIC_NODE_NID', 3); // define the nid for which you want to send email

function my_module_panels_post_render($panels_display, $renderer) {
  $content = $panels_display->content;
  foreach ( $content as $key => $value) {
    if($content[$key]->type == 'node' && $content[$key]->configuration['nid'] == MY_SPECIFIC_NODE_NID){
      dpm('This is my node. I will send email here!');
      // Uncomment the line below to actually send email - remember to substitute variables appropriately
      // drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE);
    }
  }
}

It should work for your scenario.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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