I need some help with the redirect conditions. I need to be able to redirect to node/add/whatever if they are in a specific role and have not already created a node for whatever. For the URL destination settings i am using a PHP snippet to test for which role they belong to and that part works perfectly. In the Redirect Conditions I am also trying to use a PHP snippet, but I can't seem to get it to work at all. Here is what I have as my Redirect snippet

if ($user->roles[DRUPAL_VENDOR_RID] == 'vendor' {
   $result = db_query('SELECT * from {node} WHERE uid=%d and type='%s'',$user->uid,'vendor_form');
   return $result;
}

I've tried variations of this snippet, but nothing seems to work.

Thank you for your help!

Comments

rsvelko’s picture

Status: Active » Postponed

you have many mistakes :)

Will help you after the new version works and is released.

And after you update to it.

cybermache’s picture

It seems to me like your code's main misses are that you aren't returning a url and that you are missing a check to see if there is any content for that user. Perhaps.

global $user;
if (in_array('vendor', $user->roles)) {
   $result = db_query('SELECT nid FROM {node} WHERE uid=%d and type='vendor_form', $user->uid);
   if ($result != NULL) { // or maybe this should be ($result > 0)
   return '<front>'; // or wherever you want to take them if they already created a vendor_form
   }
   else {
   return 'node/add/vendor_form';
   }
}
else {
   return '<front>'; // or wherever you want to take them
}

This is using version 6.x-2.12.

priyankprajapati’s picture

Issue summary: View changes

Hi friends.

I have download and install the drupal 7.32. i use many custom module in my site. before some days my core login functionality work properly. after that i have instal and uninstall many module.

now when i enter the proper credential after that i click on the login button that time page can't be redirect. its not work properly. when we refresh the page then it will display the login successfully

when we click on login button many time but page can t be redirect

so how can i solve the my problem ?