I am trying to integrate this module with login destination. Basically what I want to do is use a code snippet in the login destination module admin. This snippet needs to return the path for adding a profile node for the logged in user if a profile node does not already exist.

What I need is some idea of how to detect if a content profile node exists for the user that has just logged in.

any ideas/tips for how to get this information?

Thanks

Comments

rjbrown99’s picture

Here's a block that works for me.

global $user;
$node = content_profile_load('profile', $user->uid);
if (empty($node)) {
return 'node/add/profile';
} else {
return 'node';
}

My profile content type is 'profile' as you can see in the second line.

ressa’s picture

Thanks rjbrown99, I used your example in my lengthy Login Destination snippet. The profile content types are 'customer_unit' and 'partner'.

global $user;
if (in_array('customer', $user->roles)) { // Page for 'customer'
  $node = content_profile_load('customer_unit', $user->uid);
  if (empty($node)) {
  return 'user/' . $user->uid . '/profile/customer_unit';
  }
}
 elseif (in_array('partner', $user->roles)) { // Page for 'partner'
  $node = content_profile_load('partner', $user->uid);
  if (empty($node)) {
  return 'user/' . $user->uid . '/profile/partner';
  }
}
 elseif (in_array('manual', $user->roles)) { // Page for 'manual'
  return 'manuals';
}
 elseif (in_array('editor', $user->roles)) { // Page for 'editor'
  return 'node/add'; // Page for 'editors'
}
else {
    return 'user/'; //User does not have 'special users' role.
}