Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to limit the option "Promoted to Front Page" per role. For example, a user with role "promoter" should only be able to promote 5 nodes a day to promote to front page. And same with sticky option.

I am using 'rules_link' module as well.

Any help.

share|improve this question

You can achieve above by writing a small custom module in Drupal... Steps are outlined below to achieve the same.

  • Create install file and define schema hook with table name as user_promote_counter with below fields
  • uid, timestamp, nid
  • Using hook_node_presave($node) update above table with a record of uid, timestamp, nid of the node updated whenever promote is set to true so that you can track only promoted to front page actions.
  • Use hook_node_validate($node, $form, &$form_state) in your custom module to verify current user who has promoter role exceeded the limit of 5 by querying above table using timestamp and uid columns. Raise an error if limit is exceeded. That will prevent user to promote more than 5 nodes per day.
share|improve this answer
You rocks man. I am almost there now. :) – TanvirAhmad Feb 24 '14 at 14:26
I will be putting all the code when I am done, to help others if they are in the same requirement. – TanvirAhmad Feb 24 '14 at 14:27
in hook_node_presave, I can compare the filed value if it was going to be checked or not by using...if ($node->promote == 1 && $node->original->promote == 0){}, but cant do it in hook_node_presave. Any help? – TanvirAhmad Feb 24 '14 at 18:52
More explanation, I want to validate if a checkbox is going to be newly CHECKED or it was already CHECKED. – TanvirAhmad Feb 24 '14 at 19:17
You can run a query to get old value on node table by nid as a condition... For Example: Forum module does this to get old tid from database here drupalcontrib.org/api/drupal/… – Anil Sagar Feb 25 '14 at 3:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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