0

I have a rule for returning users to finish creating a cck form. I need to 'Do' custom PHP code to redirect the user to editing/finishing their cck form (node limiter limits user to only one PPE content item). The following does not work:

function ppe_edit_user_login(&$edit, $account) {
  global $user;
  $nid = db_query('SELECT nid FROM {node} WHERE uid = :uid', array(':uid' => $user->uid))->fetchField();
  drupal_goto('node/' . $nid . '/edit');
}

What am I missing?

2
  • Can you verify that the function gets called, for example by having it print something then exit?
    – richardg
    Commented May 24, 2011 at 13:49
  • @richardg thanks for the suggestion. I added a phpinfo(). A message in the same Do gets set, but the function does not seem to get called. If I add phpinfo(); all by itself, it prints. If I strip the func and only have the mid three lines, I get white screen.
    – Tom
    Commented May 24, 2011 at 21:47

2 Answers 2

2

Here is the right code, or at least code that works:

$nid = db_result(db_query('SELECT nid FROM {node} WHERE uid = %d', [account:uid]));
$_REQUEST['destination'] ='node/' . $nid . '/edit';
2
  • this one is D6 code, the first was D7. But I think [account:uid] should be $user->uid.
    – nonsenz
    Commented May 25, 2011 at 18:37
  • "[account:uid]" is used in PHP code run inside a rule action, and it is replaced with the user ID of the currently logged in user.
    – avpaderno
    Commented Sep 21, 2011 at 12:52
1
function ppe_edit_user_login(&$edit, $account) {
  global $user;

  $nid = db_query('SELECT nid FROM {node} WHERE uid = :uid', array(':uid' => $user->uid))
    ->fetchField();

  drupal_goto("node/$nid/edit");
  exit;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.