I mentioned this in another post but thought it might need its own entry.

I am trying to create a rule that redirects a user if the author of a node the user is viewing has no relationship to him. So a user gets on the site and tries to go to another users node and doesn't have a relationship with that user he is redirected to a page that explains the user needs a relationship to view the node. If a user has a relationship with a user they can see each others nodes. I have tried multiple configurations with rules trying to get this to work but it either wont let me add a condition or it doesn't work at all. Please help me! I appreciate your time. Thanks.

Comments

DevJoshLopez’s picture

Here is an update with my rules log and the error im getting.

0 ms Reacting on event Content is viewed.
12.411 ms Evaluating conditions of rule Chek for user relationship access. [edit]
12.859 ms The condition node_is_of_type evaluated to TRUE [edit]
55.353 ms The condition user_relationships_rules_condition_users_are_related evaluated to FALSE [edit]
55.366 ms AND evaluated to FALSE.

This is supposed to be evaluated to TRUE

It also shows this error message

Notice: Trying to get property of non-object in user_relationships_rules_condition_users_are_related() (line 212 of /home/pville/public_html/sites/all/modules/user_relationships/user_relationships_rules/user_relationships_rules.rules.inc).
Notice: Undefined property: RulesCondition::$uid in user_relationships_rules_condition_users_are_related() (line 212 of /home/pville/public_html/sites/all/modules/user_relationships/user_relationships_rules/user_relationships_rules.rules.inc).

drewish’s picture

DevJoshLopez’s picture

I have moved to the dev release and am still getting errors just trying to display a message if two users are related. Here is an export of what I have that is not working.

{ "rules_check_if_user_can_access" : {
    "LABEL" : "check if user can access",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "user_relationships_rules", "rules" ],
    "ON" : [ "node_view" ],
    "IF" : [
      { "user_relationships_rules_condition_users_are_related" : { "user1" : [ "node:author" ], "user2" : [ "site:current-user" ] } }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "You are related!", "type" : "warning" } }
    ]
  }
}

even with the dev version im getting this error.

Notice: Trying to get property of non-object in user_relationships_rules_condition_users_are_related() (line 213 of /home/pville/public_html/sites/all/modules/user_relationships/user_relationships_rules/user_relationships_rules.rules.inc).
Notice: Undefined property: RulesCondition::$uid in user_relationships_rules_condition_users_are_related() (line 213 of /home/pville/public_html/sites/all/modules/user_relationships/user_relationships_rules/user_relationships_rules.rules.inc).

matthand’s picture

Category: support » bug
Priority: Normal » Major

I've tried many different methods but I am still getting this same warning with any use of User Relationships in Rules. I've done some debugging and pinpointed the first recursion occurs during the AJAX function in the UR form. This file here: user_relationships/user_relationships_ui/user_relationships_ui.forms

Here's some debugging output where you can see the recursions:

 4: drupal_get_form() (Array, 2 elements)
      file (String, 21 characters ) includes/form.inc:131
           $...[' 4: drupal_get_form()']['file']
      args (Array, 2 elements)
           $...[' 4: drupal_get_form()']['args']
                  0 (String, 29 characters ) user_relationships_ui_request | (Callback) user_relationships_ui_request();
                         $...[' 4: drupal_get_form()']['args'][0]
                  1 (Object) stdClass
                          ∞ (Recursion)
 3: user_relationships_ui_request_ajax() (Array, 2 elements)
      file (String, 93 characters ) sites/all/modules/user_relationships/user_relat...
             sites/all/modules/user_relationships/user_relationships_ui/user_relationships_ui.forms.inc:70
      args (Array, 1 element)
             0 (Object) stdClass
                    ∞ (Recursion)
 2: call_user_func_array() (Array, 1 element)
      args (Array, 2 elements)
             0 (String, 34 characters ) user_relationships_ui_request_ajax | (Callback) user_relationships_ui_request_ajax();
                  $...[' 2: call_user_func_array()']['args'][0]
             1 (Array, 1 element)
                 0 (Object) stdClass
                      ∞ (Recursion)

Anybody have a clue as to why the user entity is not called correctly?

matthand’s picture

I forgot to mention that I applied the patch from the issue that Drewish shared. And, I still received the same error messages.