Organic Groups URL destination
stormer - June 17, 2007 - 02:44
I'm running a CMS which restricts access by using OG. As such users are registered to one group or another and in order to do away with unnecessary clicks I'd like a user to be automatically directed to the group front page to which they belong. As such if I belong to the 'design' group, the system should automatically redirect me to the 'design' home page when I log in. Is there a module that will enable this for me? I've played around with "login-destination" but it does not seem to allow me to set individual redicrects.
thanks very much.

Login Destination + Profile module = Individual redirects
I use the core profile module together with Login Destination to offer a "login page" feature on my sites. Here's how to do it on yours.
1. Set up a new Profile field
First enable the profile module, set its permissions accordingly and create a new profile field:
Category: Login settings
Title: Login page
Form name: profile_login_url
Type: URL
Explanation: Enter the full URL for the page you would like your login destination to be. For example, enter http://example.com/group/design if you want to go to the Design Group home page immediately after logging in.
It's up to you, but I usually set this profile field to "Private" instead of "Hidden" so site members can click on it when viewing their own profile.
2. Set up a Login Destination
Finally, configure Login Destination to use a PHP snippet and paste this in:
global $user;if (!$user->profile_login_url == "") {
// check to see if Login URL is set
return $user->{profile_login_url};
} else {
// no Login URL is set so go to user's profile
return 'user';
}
3. Check your account settings
Now you and your users will have a new "Login settings" tab on the account settings page with a "Login page" setting.
brilliant
thanks very much for that.
not picking up the redirect page i set in the user options
hi
i have followed the instructions, but for some reason profile_login_url is not being picked up, i changed the "no login" code( // no Login URL is set so go to user's profile
return 'user';) to another page to check if the script is okay and it is, it seems that the script is not picking up the new field i made for (URL profile) each user.??
any ideas to what i can check?
thanks
What is the machine-readable
What is the machine-readable "Form name" you entered for the custom profile field? Whatever it is, use the same name (in this case,
profile_login_url) in the Login Destination PHP code.Meanwhile, I'm not returning
useranymore. It's annoying when a user tries to go to a private page but isn't logged in (and gets an "access denied" message), he or she logs in and is then sent to the user profile instead of the private page. I've opted to use the referring page instead.global $user;if (!$user->profile_login_url == "") {
// check to see if Login URL is set
return $user->{profile_login_url};
} else {
// go to the referring page (yes, referrer is mispelled in the HTTP specification)
$referrer = strtolower($_SERVER["HTTP_REFERER"]);
return $referrer;
}
This way Drupal acts normally if no Login URL is set in the "Login page" field. I use LoginToboggan to show a login form on my access denied (403) page, so that may be a prerequisite.
Not working also
Hi,
I tried to do as above described.
Are these the right settings for login_destination module:
-----------
NOT CHECKING: Preserve destination
PHP snippet (experts only)
global $user;if (!$user->profile_login_url == "") {
// check to see if Login URL is set
return $user->{profile_login_url};
} else {
// go to the referring page (yes, referrer is mispelled in the HTTP specification)
$referrer = strtolower($_SERVER["HTTP_REFERER"]);
return $referrer;
}
CHECKING ALLWAYS: Redirection condition settings.
I also checked if the profile_fieldname in the database is the same, this is the case..
Please help..
greetings,
Martijn
Looks right to me
At admin/user/profile (Administer -> User management -> Profiles), is the "Name" field set to
profile_login_urlor something else?That looks right to me. For what it's worth, I have "Preserve destination" checked but I don't think it should matter. The checkbox for "Redirection condition settings" is checked and the textfield is blank.
Multidomain installed or not
Hi,
Yes the "Name" field is set to profile_login_url.
I also tried it with the multidomain module installled and not-installed.
I am not getting this to work...
could there be something else happening. I also have single-signon installed.
Day further.. I am not getting this to work correct. I got another page then the superadmin page when I log in as another user.
But the page I got is from another user. Should there may be a couple of variables been cleaned in the code? For the next login?
Another day further...
I tried using this solution on www.isnow.in/user/login
global $user;if (!$user->profile_login_url == "") {
// check to see if Login URL is set
return $user->profile_login_url;
} else {
// go to the referring page (yes, referrer is mispelled in the HTTP specification)
$referrer = strtolower($_SERVER["HTTP_REFERER"]);
return $referrer;
}
It gives
Access deniedYou are not authorized to access this page
Please help!
Thanks in advance,
greetings,
Martijn
Access Denied
Hi,
I left the path of trying to solve this with the login-block on the homepage.
I deselected the login block.
The www.isnow.in/user/login has (as shown in lots of drupal threads..) better functionality.
So I am trying to get it to work on this path to hapiness!
But when I try to log in.
I get the right navigation block, but the content is not shown.
I got the
Access deniedYou are not authorized to access this page
When I deinstall the login_destination module, I got my regular profile page with now the profile login url shown. So in my perspective is has to do with php snippet.
Does anybody else have the same behaviour?
The snippet I still use is:
global $user;if (!$user->profile_login_url == "") {
// check to see if Login URL is set
return $user->profile_login_url;
} else {
// go to the referring page (yes, referrer is mispelled in the HTTP specification)
$referrer = strtolower($_SERVER["HTTP_REFERER"]);
return $referrer;
}
thanks in advance!
greetings,
Martijn
Login Destination + Single Sign-on = ?
I'm not sure that the Access denied errors are due to Login Destination or not but I haven't tried the two modules together. Do custom PHP rules in Login Destination work when Single Sign-on is disabled and the login URL is on the same site (and not another subdomain).
I'll be interested to see what answers turn up at http://drupal.org/node/190065.
Access denied
I disabled Single Signon and got also access denied with a login URL on the same site.
Sorry..
I hope this helps in your investigation. Thanks for getting into this!
Greetings,
Martijn
Does Login Destination do
Does Login Destination do its work when it's set to use a "static URL" instead of a "PHP snippet"? Try this with Single Sign-on disabled and again with SSO enabled.
If the static URL in Login Destination works with a static URL and with SSO enabled then the problem can be narrowed down to the PHP snippet. If it doesn't work when SSO is enabled and you are using the PHP snippet you posted above (the snippet looks OK to me), then the problem may be with SSO (or worse, the Drupal login system).
There are a lot of variables here to test and I only have a minute to write this. I'm sorry for not elaborating more or if parts of what I wrote here don't make sense.
>>That looks right to me.
>>That looks right to me. For what it's worth, I have "Preserve destination" checked <<
At the risk of asking a stupid question...
How do I turn on "Preserve destination"? There is no checkbox for this on the Login Destination settings page. I have spent most of day searching the forums and looking through every nook and cranny of the administration section trying to figure out how to do this. Do I need to use a PHP snippet or is there a checkbox somewhere that I have missed.
Thanks in advance for any help!
It's in the current dev version
The "Preserve destination" checkbox was added quietly to the dev version a few months ago. Try that version (it looks like you're using the 5.x-1.0 release) and see if it has any effect.
My heart is broken to hear that you spent a day trying to find that checkbox. The only advice I can think of giving is to ask developers to use more descriptive CVS commit messages.
Doh! Thanks for the tip-the
Doh! Thanks for the tip-the dev version does what I need it to. I guess that's part of fun of working with an open source program. I'm just glad these forums are here.
Thanks again
not reading the URL in user settings
I am using Drupal 5.5, theme is itheme, and the sept 2007 dev version of Login Destination and it doesn't read the URL from the user settings:
Here is the code I am using:
global $user;if (!$user->profile_login_url == "") {
// check to see if Login URL is set
return $user->{profile_login_url};
} else {
// go to the referring page (yes, referrer is mispelled in the HTTP specification)
$referrer = strtolower($_SERVER["HTTP_REFERER"]);
return $referrer;
}
Of course loaded as snippet
*Note: if FCKeditor is enabled, then it adds HTML markup to the PHP snippet.
I also have the profile setting as: profile_login_url with the type as URL.
There are no unique log messages in drupal or apache.
I was previously on Drupal 5.3 where is did not function either.
Any advice?
***updated-the information from user settings is not writing to the database. I manually created the field "profile_login_url" and manually added the redirect URL then it works. Everything else with the database seems to work find as I am able to add users and content without any problems.
I'm glad you found the
I'm glad you found the problem. Thank you for following up.