2

When I go to /user/uid I want it to go to /content/content-profileID by default. This is a node typer that is used by content profile.

How can I go about doing this?

1
function MYMODULE_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'view':
      profile_load_profile($account);
      // Now $account will contains all profile data;
      // some code
      break;
    }
  }
}
1
  • I'd expect content profile to provide this... – Capi Etheriel Mar 30 '11 at 15:39
0

I created a function that given a uid it would return the profile nid. I then added to hook_user to redirect to node/profileID on view.

function MY_MODULE_USER($op, &$edit, &$account, $category = NULL){
    switch ($op){
        case 'view':
            $profileNid = MY_MODULE_getProfileNidFromUid($account->uid);
            drupal_goto("node/" . $profileNid);
            break;
    }
}

function MY_MODULE_getProfileNidFromUid($uid){
    $sql = "SELECT nid FROM node WHERE TYPE =  'profile' AND uid =" . $uid;
    $profileNid = "";
    $dbResults = db_query($sql);

    while ($result = db_result($dbResults )) {
        $profileNid = $result;
    }
    return $profileNid;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy