I'm using the Drupal Commerce 7.x, Rules Link, and Content Access modules.

In my site Classified ads can be created, and then people can use credits (via User points) to pay for unlocking "contact informations".

For example, when an advertiser creates an ad, 2 things happen:

  • content (node) of type "Classified ad" is created, and
  • it is cloned and converted in another content (node) of type "Classified complete".

So there will be 2 different nodes: the first one is a "Classified ad" and the second one is a "Classified complete".

The "Classified ad" is the node which has limited information and the "Classified complete" is the node which has all information. They are all linked together with the "Rules link" module.

The "Classified ad" node is displayed for everyone and the "Classified complete" node linked to it can be accessed only if a user paid for it already.

More info about my current setup as described above is included also in my related question "How to access node properties of another node using the Rules Link module?".

Now I want to further refine the display of the link shown via "Rules Link": I want to display a link rules in "Classified ad" nodes only if all these conditions are satisfied:

  • The current user is an authenticated user (done, as per my linked question).
  • The current user already bought the node "Classified complete" so the user has an access granted to that node (with the Content access module).
  • A page redirect to the node "Classified complete"(done, as per my linked question).

How to check if my current logged in user already has the access granted to a node id (the 2nd condition in the previous list)?

1 Answer 1


From the (my) accepted answer to your related question (= How to access node properties of another node using the Rules Link module?), I do remember that apart from the Content Access module, you ALSO use the ACL module.

However, even though via the ACL module you do get some extra Rules Actions (such as content_access_action_user_grant), there doesn't seem to be (or at least I have not found it yet) a Rules Condition that you could use to check that "the current user already bought the node" (as in your question here).

Too bad, if IT IS NOT available, then just MAKE IT available. For that, you can use the Flag. If you then configure a (non-global) flag, you could use that flag like so:

  • When configuring the flag, only allow it for bundle 'Classified Ad'. And make sure to only grant access to the flag to users with a role like "special role for Classified Ads" (name it what you want), to avoid the link to flag such nodes would be shown to unauthorized users (due to which they could flag the node just using the UI, which you do not want to happen).
  • Around the time the user buys access to your 'Classified complete' node, perform an additional Rules Action to "flag the 'Classified Ad' node by the current user as bought", and with the machine name of the flag (say) 'node_bought' (pick whatever fits).
  • Within the Rules Link, use a condition like "Is the node flagged with the 'node_bought' flag by the current user?".

Below is a (rather basic) Rules Component (= condition set (AND) "Rules link: authenticated user Link contact infos condition") with machine name to match your existing Rules Link also, as in your linked question. And which you could use for this (change the machine name of the flag from 'node_bought' to your flag's machine name, prior to importing this):

{ "rules_link_condition_access_to_contact_info_links" : {
    "LABEL" : "Rules link: authenticated user Link contact infos  condition",
    "PLUGIN" : "and",
    "OWNER" : "rules",
    "REQUIRES" : [ "flag" ],
    "USES VARIABLES" : { "node" : { "type" : "node", "label" : "node" } },
    "AND" : [
      { "flag_flagged_node" : {
          "flag" : "node_bought",
          "node" : [ "node" ],
          "flagging_user" : [ "site:current-user" ]

Something I'm unsure about right now (= homework for you to QA-test): as per that "special role for Classified Ads" (see before), the (extra) Rules Action to flag the node may fail (not authorized for current user). If that's the case, then just add these 2 extra Rules Actions as a work around for that:

  • Grant access for current user to "special role for Classified Ads", right before the Rules Action to flag the node.
  • Remove access for current user to "special role for Classified Ads", right after the Rules Action to flag the node.
  • This is exactly what i wanted ! Thank you so much ! i didn't had to grant access to the special role, in the rules conditions, on the flag node option there is a check box to skip permission :) Thanks again @Pierre, now i understand how far we can go with flags, it will be usefull in my futur projects <3
    – Quentin
    Jan 9, 2018 at 14:49
  • Yeh, yet another "issue" sorted out ... And merci for the accept, and "+1"! ... Also, just for you to know, "Flag" is one of my "must-have-in-every-D7-site-modules", the complete set is "VFRMG", aka "Views-Flag-Rules-Message-Group". With only these 5 (!!!) modules enabled, I can deliver at least 90% of any functionality of any site ... With ZERO custom code ... So how is your knowledge of the "Message" module? If you've never used it, put it on your must-review-list ... Jan 9, 2018 at 15:09
  • You deserve more than +1 :p, i don't know "message" and "group" modules, i will check these thanks for the advice !! :)
    – Quentin
    Jan 9, 2018 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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