6 deleted 201 characters in body
source | link

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?

Code with suggestions added:

global $user;
$node = node_load([node:nid]);

if ($node->uid == $user->uid) {
  return TRUE;
}
else {
  return FALSE;
}

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?

Code with suggestions added:

global $user;
$node = node_load([node:nid]);

if ($node->uid == $user->uid) {
  return TRUE;
}
else {
  return FALSE;
}

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?

5 Code formatting according to Drupal coding standards
source | link

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$node and $user$user variables are not being recognised. I'm not sure why this is the case, do I need to use the node_loadnode_load() and user_loaduser_load() functions before using these variables? If so how?

Code with suggestions added:

global $user;
$node = node_load([node:nid]);

if ($node->uid == $user->uid) {
  return TRUE;
}  
else {
  return FALSE;
}

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?

Code with suggestions added:

global $user;
$node = node_load([node:nid]);

if($node->uid == $user->uid){
return TRUE;
} else {
return FALSE;
}

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?

Code with suggestions added:

global $user;
$node = node_load([node:nid]);

if ($node->uid == $user->uid) {
  return TRUE;
} 
else {
  return FALSE;
}
4 added 188 characters in body
source | link

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?

Code with suggestions added:

global $user;
$node = node_load([node:nid]);

if($node->uid == $user->uid){
return TRUE;
} else {
return FALSE;
}

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?

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?

Code with suggestions added:

global $user;
$node = node_load([node:nid]);

if($node->uid == $user->uid){
return TRUE;
} else {
return FALSE;
}
3 edited tags
| link
2 added 106 characters in body
source | link
1
source | link