If an imported user has not either logged into their account for the first time, or had user 1 edit and save their account, roles with the 'access user profiles' permission will not be able to view the imported user's profile. By setting the 'access' value in the user table, the profile can be viewed.

function MY_MODULE_uif_post_create($account, $user_data, $form_state) {
  $update['access'] = time();
  $updated = user_save($account, $update);
}

Comments

dwightaspinwall’s picture

I'm not familiar with the "view user profiles" permission. What module implements it and which version of Drupal?

agileware’s picture

My bad, that should be the 'access user profiles' permission.

dwightaspinwall’s picture

Ok, so core profile module. Here's what user_save() does:

// Consider users created by an administrator as already logged in, so
// anonymous users can view the profile (if allowed).
if (empty($array['access']) && user_access('administer users')) {
  $array['access'] = time();
}

So is the proposal that all users created by uif get access set as well (and not just those created by users with 'administer users' perm)? I guess that makes sense.

adammalone’s picture

Title: Users cannot view imported user's user page. » Users cannot view imported user's user page. [Patch Attached]
Status: Active » Needs review
StatusFileSize
new714 bytes

I took a look at the code and this looked like the right way of altering the module to include this.

dwightaspinwall’s picture

Status: Needs review » Fixed

Fixed in 6.x-1.5 / 7.x-1.0-beta8 Thanks!

dwightaspinwall’s picture

Status: Fixed » Closed (fixed)
dwightaspinwall’s picture

Issue summary: View changes

Correction