My scenario is:
- invite with "New user registration by invitation only"
- Drupal for Facebook with user module to let people create new account through facebook connect
From the /user/register page, if you click on the facebook connect button, everything works fine, except that at the end you get an "Access Denied" error, saying that you need to have an invitation...
The problem is probably due to the fact that Drupal for Facebook redirects you to the same page where you came from, so /user/register. The output of /user/register is controlled by the function invite_user_register_access
function invite_user_register_access() {
$invite = invite_load_from_session();
// Legacy url support (user/register/regcode).
if (!$invite && $code = arg(2)) {
if ($invite = invite_load($code)) {
if (invite_validate($invite)) {
$_SESSION[INVITE_SESSION] = $invite->reg_code;
}
}
}
if (!$invite && !user_access('administer users')) {
// The menu system checks access whenever local tasks are displayed. Make
// sure the message is output only for the path user/register.
if (arg(1) == 'register') {
drupal_set_message(t('Sorry, new user registration by invitation only.'));
}
return FALSE;
}
// Let the default handler take care of standard conditions.
return user_register_access();
}
So, the problem is that this function doesn't control if you are already registered and display an error message. BTW, this is the normal behaviour of drupal: even if you are admin and go to user/register page you get Access Denied error.
The easiest way I found to solve my problem is to hack this function and add, just at the beginning these two lines:
global $user;
if ($user->uid){drupal_goto("user");}
If the user is already registered (i.e. if he pressed the connect button and went through the entire facebook connect registration) it redirects him to the profile page, which is good in any case in my site if inadvertently one user goes to the user/register page.
I would appreciate any comment to solve this problem in cleaner way...
Comments
Comment #1
dale42I'm helping the Invite module maintainers by cleaning up old issues.
Drupal 6 is no longer supported so I'm setting the issue status to Closed (outdated). Information on what that means is here: Issue Status field.
If you have a question about one of the current versions of the module please do submit a new issue.