Automatically redirect members to their profile page when they login.
Copy code into a file called NP_LoginRedirect.php and upload to your plugins directory.
Install the plugin…
No further setup needed. You can disable it from the plugin options.
Uninstall previous version if less than 0.40 (from admin area)
Copy new file over old file
Install the plugin from admin area
Set the options as desired
Just install it and it works.
Should login redirect be enabled? - Whether the login is enabled or not. (Yes). You can temporarily disable it here without uninstalling the plugin, if needed.
destination - Destination of redirect. (member profile page). Select member profile page, site top (main index of site), or custom.
Custom Destination - Destination of redirect. Full
URL to redirect target page. See Tips and Tricks for explanation of variables available in this option text.
In the custom destination option field, you can use the following variables from the member object or from NP_Profile fields (if installed)
%url% - Value of the Member Website Address (
URL) field of the member who just logged on
%nickname% - member display name
%fieldname% - value of fieldname in members profile (NP_Profile). Not all fields are available. Excluded are fields of type password, file, list, textarea, mail, and date.
Examples:
1. To custom redirect to the Website Address (URL) of member:
%url%
2. To redirect to a subfolder named for members nickname:
http://www.example.tld/%nickname%/
3. To redirect to a special page named for members zodiac sign (stored in 'zodiac' field of NP_Profile):
http://www.example.tld/index.php?special=%zodiac%
The plugin doesn't work with Fancy URLs (like item/11) and Fancier Urls (like item/this-is-a-title). Reported by kg.
Note from plugin author: In theory, the plugin should not depend on the URL scheme because it simply hooks into the postlogin event and redirects to the member's page. Where the URL to the member's page is created using the createMemberLink() method and should create the member url correct according to the scheme in use, if the scheme is properly using the GenerateURL event. I have tested this plugin successfully using Fancy URLs (member/1) and using NP_CustomURL (member/webmaster.html). I have not tested using NP_FancierURL2. kg, could you contact me, or post on the forum thread to give more details about what is failing in your environment - ftruscot
It seems that the 'MemberKey' get lost in Nucleus 3.31. I have no real explanation for it. But as a workaround I have changed the function event_LoginSuccess so that it set the lost value:
function event_LoginSuccess(&$data) {
if ($this->getOption('redirect_enabled') == 'yes') {
global $shared, $CONF;
$errormessage = '';
ACTIONLOG::add(INFO, "Login successful for ".$data['member']->displayname." (sharedpc=$shared)");
$CONF['MemberKey'] = 'member';
$url = createMemberLink($data['member']->id);
header("Location: $url");
exit;
}
}
Note from plugin author. More discussion at the forum thread, but I tweaked kg's suggestion and added it to v 0.3. So this should be fixed as of v 0.3.
NP_LoginRedirect version 0.2 works with Nucleus CMS version 3.31 - 2007-11-14 kg