NP_LoginRedirect.php

Automatically redirect members to their profile page when they login.

General Plugin info
Author: Frank Truscott, yama
Current Version: 0.40
Code: NP_LoginRedirect Code
Download: :np_loginredirect_v040.zip
Demo: N/A
Forum Thread: Here

Installing

  1. Copy code into a file called NP_LoginRedirect.php and upload to your plugins directory.
  2. Install the plugin…
  3. No further setup needed. You can disable it from the plugin options.

Upgrading

  1. Uninstall previous version if less than 0.40 (from admin area)
  2. Copy new file over old file
  3. Install the plugin from admin area
  4. Set the options as desired

How to use the plugin

Just install it and it works.

Available SkinVars and/or TemplateVars

  • None

Options

  • 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.

Tips and Tricks

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%

Wishlist

Bugs

  • 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.

History

  • 0.3 released 15 November 2007
    • fix bug of failure with certain fancy url methods. Thanks kg.
  • 0.2 released 15 March 2007
    • initial

Plugin review

NP_LoginRedirect version 0.2 works with Nucleus CMS version 3.31 - 2007-11-14 kg

loginredirect.txt · Last modified: 2010/10/21 06:06 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki