Send an email notification to admin prior to poll close date I'm using Advanced Poll module and it has a nice "Time management" feature. We can schedule when to open or close the poll.

I want to send an email notification to the administrator one day prior to poll close date. So that, admin gets notified and create an another poll.

Is there any way to make this possible with Rules module or hooks?
You will need to create a Rule that will schedule component evaluation (send email).

CREATE COMPONENT


Create component plugin of type Rule (admin/config/workflow/rules/components/add) - name it "Notify admin about poll closure".
Provide a variable for the component to act on. Variable Data type = Content, Label - Poll Node, Machine name = poll_node, Usage = Parameter.  





Add Conditions if you need any
Add Actions -> Send HTML e-mail. Set you email parameters
below is the export of the component

{ "rules_notify_admin_about_poll_closure" : {
    "LABEL" : "Notify admin about poll closure",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules_i18n", "rules", "mimemail" ],
    "USES VARIABLES" : { "poll_node" : { "label" : "Poll Node", "type" : "node" } },
    "DO" : [
      { "mimemail" : {
          "key" : "poll_closure_notify_admin",
          "to" : "adminemail@email.com",
          "subject" : "Poll will close tomorrow",
          "body" : "Poll [poll-node:title] will close tomorrow",
          "plaintext" : [ "" ],
          "language" : [ "" ]
        }
      }
    ]
  }
}  





CREATE RULE


React on Events: "After saving new content of type Advanced Poll", "After updating existing content of type Advanced Poll"
Add Conditions "Entity has field": Entity: node, Field: advpoll_dates
Add action "Schedule component evaluation" - select the component that you created "Notify admin about poll closure".  

Scheduled Evaluation date -> node:advpoll-dates:value2. Add offset "-1 days". This will schedule the email 1 day before poll closing.  

Set an identifier to something like "Poll closure notification: [node:nid] - [node:title]". It should have unique values everytime new scheduled task is added in queue, that is why you should use node:title and node:nid.

Set Poll Node field to node.

Save your rule and test.

{ "rules_schedule_notification_about_poll_closure" : {
"LABEL" : "Schedule notification about poll closure",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_scheduler" ],
"ON" : {
  "node_insert--advpoll" : { "bundle" : "advpoll" },
  "node_update--advpoll" : { "bundle" : "advpoll" }
},
"IF" : [
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "advpoll_dates" } }
],
"DO" : [
  { "schedule" : {
      "component" : "rules_notify_admin_about_poll_closure",
      "date" : {
        "select" : "node:advpoll-dates:value2",
        "date_offset" : { "value" : -86400 }
      },
      "identifier" : "Poll closure notification: [node:nid]",
      "param_poll_node" : [ "node" ]
    }
  }
]}}





I provided an export of the component and the rule that you can use and modify to your preference. Hope this helps.

P.S. Cron should be enabled and configured on your website in order for scheduled events to work properly.