How to display a Rules Link only if access to display the linked content was granted? 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)?
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.