I need to show an "Add content" link to users but I need to consider user field values to give access to the node form. For example, is the boolean field "Subscription fee paid" is True.
I thought the Rules module could help me. But I can not find any event "Before creating new content", only "Before saving content". Indeed, I do not want users to fill the form before conditions are verified. Because after 5 or 10 minutes of completing a form, it would not be user-friendly to get a warning message like "*you are not allowed to do that!" ...
So I tried Rules link to create a sort of button, with conditions and reactions. For example, in a block, I show the Rules link. When accessed, if conditions are true, I redirect the user to the form. Unfortunately, Drupal uses the Rules link path by default (for example, submit-the-form) and not the redirection page url included in my rule (for example: node/add/article
) and finally the page is not found, since nothing is behind the default path.
Well, I guess I am close but still stuck. Any suggestions?
EDIT : I have tried to create a rule, as suggested by @Pierre.Vriens. Here is the short code.
{ "rules_subscription_check" : {
"LABEL" : "Subscription check",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "path" ],
"ON" : { "init" : [] },
"IF" : [
{ "path_has_alias" : { "source" : "[site:url]\/node\/add\/manuscript-submission" } },
{ "data_is" : { "data" : [ "site:current-user:field-subscribed" ], "value" : "0" } }
],
"DO" : [
{ "drupal_message" : {
"message" : "Sorry, subscription is needed to add that type of content.",
"type" : "warning",
"repeat" : "0"
}
},
{ "redirect" : { "url" : "no_access" } }
]
}
}
Unfortunately, an unsubscribed but authentified user can still add content when he clicks on the form link.