I am trying to execute a Rule based on the condition of whether the currently logged in user, is currently viewing their node (a node they are the author of), or viewing someone else's node. The Rule event/trigger I am using is "User saves a Status" from Statuses module. Next I have used the Rules condition "Execute Custom PHP code", and set an if statement that checks whether the current node uid (the uid of the node's author) equals the current user uid:
if ($node->uid == $user->uid) {
return TRUE;
}
else {
return FALSE;
}
This is causing a bunch of "Trying to get property of non-object" errors, as both the $node
and $user
variables are not being recognised. I'm not sure why this is the case, do I need to use the node_load()
and user_load()
functions before using these variables? If so how?