On an openatrium installation with ucreate module, i couldn't make user roles permissions. After a couple of hours, i find the solution.

It seems the module ucreate load roles before user_roles module throught hook_user(). So re-declaring user_access in hook_user instead of hook_init seems to correct error.

Example of my own hook which redeclare user_access :

function hook_user(){
	global $user;
	
	// Roles by groups
	$space = spaces_get_space();
	
	$group = $space->group;
	$gid = $group->nid;

	$result = db_query("SELECT ogur.rid, r.name FROM {og_users_roles} ogur INNER JOIN {role} r ON r.rid = ogur.rid WHERE ogur.uid = %d AND ogur.gid = %d", array($user->uid, $gid));
   	while ($role = db_fetch_object($result)) {
   		// Add roles to account first, so we can statically cache all roles
		// afterwards.
    	$account->roles[$role->rid] = $role->name;
    	$user->roles[$role->rid] = $role->name;
    }
    
  	// Reload user permissions.
  	user_access(NULL, $user, TRUE);
}

I think edit og_user_roles_init by og_user_roles_user should resolve the bug.

Comments

goz’s picture

This not resolve probleme in all cases in fact.

I put this code in a new module in a hook_init function and give module's weight less weight than ucreate module (so -11). This fix the error.

sun’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

Could you try once again with 4.1 ?

sun’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Sorry, without further information this issue can only be marked as won't fix.

Feel free to re-open this issue if you want to provide further information. Thanks.