Can you explain how the SMF user id number relates to the drupal user id? I was expecting the user id numbers to match, but this isn't the case.

My objective is to redirect the SMF profile pages to the drupal pages - this would be an easy .htaccess rule if the UID for each was the same. However, it appears to be different - can you explain how the mapping works?

Thanks, Stephen

Comments

vb’s picture

>how SMF user id number relates to the drupal user id?
ids are absolutely independent and no way to match them in this bridge.
It is a smart, non stupid bridge which not expects that ids must be identical.
It compares usernames.

scedwar’s picture

Thanks,

What I'm therefore looking to do is edit the smfforum code for the profile page to redirect to the Drupal user page. Is there a simple function within your api where I could give the smf user id and return the drupal user id?

For example,

int get_drupal_id(int $smf_user_id);

vb’s picture

there is no this function in current ver. but can be written

vb’s picture

1) Insert somewhere in smfforum.module
2) set define('SMF_MODULE_DEBUG', 1); to see the output
3) enjoy if it helps you

It is the personal gift to you but no more lines and answers to this feature, it is not in the plans of current developement, sorry.

function smfforum_get_drupal_id($smf_id) {
  
  if (!_smfforum_settings() || empty($smf_id) || !is_numeric($smf_id))
      return 0;
  
  $username = smf_api_get_user_name((int)$smf_id);
  if (empty($username)) {
    if (SMF_MODULE_DEBUG) {
      _smfforum_set_message('The SMF userid %name is not found in SMF.', array('%name' => $smf_id));
    }
    return 0; //user not found
  }
  
  if (SMF_MODULE_DEBUG) {
    _smfforum_set_message('The username %name is found in SMF.', array('%name' => $username));
  }
  
  $account = user_load(array('name' => $username));
  
  if (SMF_MODULE_DEBUG) {
    $var = array('%name' => $account->uid);
    if ($account->uid)
      _smfforum_set_message('The Dupal uid %name is found.', $var);
    else
      _smfforum_set_message('The Dupal uid %name is not found.', $var);
  }
  
  return $account->uid;  
}