Im trying to limit the creation of nodes by user roles for eg. Subscriber (can create only 2 nodes) while Contributors (can create upto 5 nodes) by using Rules for D7.
So far its turned out pretty good but only upto displaying a message before saving node content. Instead what I am rolling over my head is to decide what user is currently logged in (particularly his role) and how many nodes he has created, then matching that node count with a fixed number, if the condition evaluates to TRUE then deny any further node creation.
On D6 this becomes a cakewalk with Node Limit module. Here is the export of Ruleset I currently have which is not much :(
{ "rules_limit_subscriber_submission" : {
"LABEL" : "Limit Subscriber Submission",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"REQUIRES" : [ "rules", "php" ],
"ON" : [ "node_presave" ],
"IF" : [
{ "user_has_role" : {
"account" : [ "site:current-user" ],
"roles" : { "value" : { "5" : "5" } }
}
}
],
"DO" : [
{ "php_eval" : { "code" : "global $user;\r\n$limit_message = 'You are not allowed to enter more than 2 entry!';\r\ndrupal_set_message($limit_message, 'warning', FALSE);\r\nprint_r($user);" } }
]
}
}