1 of 2
1
New Extensions - User Login / Logout Redirection!
Posted: 05 December 2007 04:00 AM   [ Ignore ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hi there,

Well I had seen a lot of posts on the forum about people wanting to be able to re-direct users upon logging out of the system to a page of their choosing so thought I would take the dark plunge into writing my first extensions.

Attached is V1.1 of the Logout Redirect extension and also V1.1 of the Login Redirect extension. These are very very simple and at the moment has just the one extension setting where you can provide a URL that you would like a user to be re-directed to upon successful log-in or log-out depending on which extension you are using.

You should be able to use both extensions at the same time as they shouldn’t conflict with one another as far as I know.

I hope to improve these extensions so that they could somehow be created as plugins instead so that people would be able to set the URL in there instead of the extension settings so that you could have endless redirect paths if you so desired. That’s a bit above my head for now though so I am submitting these as they are.

I hope that I have done the right thing in posting this here like this. If I haven’t then please (moderators) don’t hesitate to slap my hands or whatever as I have never done this before so any help with the correct procedure will be appreciated.

Also if maybe one of the EE admin crew could possibly look these over and make sure that it adheres to the EE coding guide-lines and that they aren’t going to cause any damage anywhere then that would also be massively appreciated.

DISCLAIMER - Please use these extension at your own risk for now as they have not been checked by anyone other than myself

Best wishes,

Mark

Installation Instructions
Download the preferred extension file from the bottom of this post. Un-zip it and follow the same directory structure as the download to place the files into their correct locations inside your EE system.
Goto your Extensions Manager in the EE admin panel and enable extensions (if they are not already enabled). Next enable the Login Redirect or Logout Redirect extension (both if you wish!!).
Click on the settings link for each extension that you have installed and fill in the URL to redirect to.

That’s it!! grin

ExpressionEngine Extension Installation Documentation

As pointed out to my hair brained self there is actually already a return parameter in the login form so you can pretty much do away with the Login Redirect extension as it probably won’t be needed by anyone after-all but hopefully the Logout Redirect extension should come in handy as that was the extension that I first made due to people needing this functionality which at the moment (I do stand to be corrected on this one though) doesn’t exist.

Mod Edit: Attachments removed.  Please review the license.

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 04:10 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Oops. I feel very very naughty now!!

I meant to say a massive massive thank you to Brian M and Dry over at this post for all their help in getting this to work.

Thanks a lot guys!! grin

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 07:01 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  780
Joined  07-18-2006

Hi Mark - I’ve got a feature request (good idea for an extension btw).  I’d love to be able to just send the person back to the page they were on when they logged out.  Maybe if you don’t fill in the logout field in settings it does this by default?  I think you could use $SESS->tracker to get this working pretty easily.

Just a thought - great first extension!

Profile
 
 
Posted: 05 December 2007 07:53 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

EDIT : UPDATED EXTENSION IN ORIGINAL POST AT THE TOP OF THIS PAGE

Ask and ye shall receive my friend. grin

Thanks for all the help on this one. I have now made it so that if you leave the settings field blank in the extensions settings then it will indeed take you back to the page you were just on.

I’m hoping I have the syntax correct to get the whole page as I am testing this on a DEV server and have index.php in there but hopefully this will still work with people who have taken out the index.php using .htaccess tricks?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 07:57 AM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Also as an aside on the Sessions Page in the documentation it says that it stores five of the last visited URLs but then goes on to say that the array’s keys range from 0 to 5. is this correct as surely that would be six wouldn’t it?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 08:27 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Quick update.

Was messing around and so thought I would make the companion extension to the Logout Redirect extension - the Login Redirect extension!! grin

You can find both latest versions at the top of this thread attached to the first post.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 08:34 AM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

UPDATE to Logout Redirect extension

I have just updated the language file for the Logout Redirect extension to inform people when they are in the settings page that leaving the field blank will send them back to the page they were just on.

Same with the Login Redirect extension. If they leave the field blank then they will just be directed to the main index page of the site.

Admittedly I think that the Logout Redirect extension is probably the better of the two as you would probably want people to be re-directed to the same place they were at upon login especially for things such as using the Simple Commerce Module so that you don’t lose your place.

I have now made the Login Redirect extension so that if you leave the settings field blank it will also take you back to the page you were recently at. I hope that I have made this in the correct way though as all I am doing is traversing through the $SESS->tracker array to return the page before the login form although I am now thinking that some people may have different login procedures that may mess this up. I will see how to get around this.

Updated files at top of thread.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 09:49 AM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Another quick update. The Login Redirect extension may not be working correctly if you are on the main index page of your site as I am testing this on a DEV server and I think that I might be spitting out the wrong URL if there is none specified in the extension settings.

The extension (Login Redirect) will hopefully work fine for all other pages on the system though. I will look into a way around this.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 10:08 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  717
Joined  07-02-2007

Is this extension used for the CP? or the front end…cause as far i know i always could do redirect on logout/login in the frontend

 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 05 December 2007 10:31 AM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hi Victor,

The Logout Redirect extension allows you to have the usual :

< a href= " {path=LOGOUT} " >Logout < /a>

links in your templates and when they are clicked you will be re-directed to a URL of your choosing or if the setting field is left blank then you should (hopefully) be returned back to the page that you were previously on.

The Login Redirect extension allows you to specify a URL that a user will be taken to upon successful login from the standard ExpressionEngine login form. If it’s setting is left blank then you should also be sent back to the same page that you were originally on.

as far as I know I always could do redirect on logout/login in the frontend

I don’t think that this is possible at the moment with the standard {path=LOGOUT} although would love to be proven wrong. Admittedly now I look into the login form tag I can see that there is the return=“site/contact” parameter so my Login Redirect extension probably is a bit useless!! :-(

Ah well it was the Logout Redirect extension which was the first one that I created and that people had been asking for so hopefully that one is still of some use? I just made the other one whilst I was at it as it were! Didn’t even occur to me about the return parameter as I was enjoying making my first extensions too much!! grin

Hope that helps.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 11:47 AM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  717
Joined  07-02-2007

Heh,

Yes, the logout link indeed does not have redirect…

FEATURE REQUEST:
Now i will need to insert a custom url in the extension settings…
I wanna insert this: $current_url (or something like that raspberry)
And that gets auto translated to the current URL.
I hope you can do that (or something similar)

Congrats on your first extension..
Keep them coming.

Thanks,
-Victor

 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 05 December 2007 11:54 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  780
Joined  07-18-2006

If you leave the settings field blank it will return you to the current page - that was my feature request too wink

Actually Mark - I think the login-redirect extension still has value. Maybe sites allow you to log in on any page and so being able to come back to the current page you logged in from has definite worth.

Profile
 
 
Posted: 05 December 2007 12:24 PM   [ Ignore ]   [ # 12 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hi Brian / Victor,

Glad you like it Brian. Victor I am looking into turning this into a plug-in instead of an extension and hope to be able to let you do something like below :

{exp:logout_redirect url="http://www.yahoo.com" extras="class='logout-link' rel='logout'"}
Logout Link
{
/exp:logout_redirect}

That would then turn the ‘Logout Link’ text into a click-able link that would allow you to log the person out and then re-direct them to the url specified in the plug-in parameter.

Having a bit of a problem with that one though at the moment and hoping that someone can help out with the post I have in the plugin forum.

Will keep you updated on all of this though.

Victor when you say you want to insert $current_url do you mean you want to put this into the extensions settings field? If all you want is to re-direct to the page you are on before you click on the logout link then if you leave the field blank then it will do the same thing for you. Is that what you meant or something else?


Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 12:50 PM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  717
Joined  07-02-2007
Mark Bowen - 05 December 2007 12:24 PM

Victor when you say you want to insert $current_url do you mean you want to put this into the extensions settings field? If all you want is to re-direct to the page you are on before you click on the logout link then if you leave the field blank then it will do the same thing for you. Is that what you meant or something else?

Yeah ....I had too little coffee this morning and didn’t read the whole post smile
It does exactly what i want when i leave the field blank

Maybe this is an better idea:

{exp:logout_redirect url="http://www.yahoo.com" extras="class='logout-link' rel='logout'" text="Logout Link"}


Some people can misinterpret the variable pair..(like putting <a href=”“> in between smile
A single variable can prevent this.

-Victor

 Signature 

Truly ExpressionEngine


Fielder Module ( Mass Custom Fields )
Super Cache (Cache heavy tag output)
reCAPTCHA Extension
Rewrite Module


See all my EE Addons (8)

Profile
 
 
Posted: 05 December 2007 12:52 PM   [ Ignore ]   [ # 14 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hi Victor,

Good idea. I might go with doing it that way instead. Probably would be better in that way. Still having problems figuring out how to get the plugin to do this anyway but hopefully soon!! grin

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 04:12 PM   [ Ignore ]   [ # 15 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1592
Joined  01-05-2007

Thanks Mark!

What situations might someone want to be redirected to another screen?

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
Posted: 05 December 2007 04:29 PM   [ Ignore ]   [ # 16 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hmmm now there’s the question!! grin

On logout you may want to take someone to an (I know very 80’s) advert about your site or some page that helps to draw them back again at a later date, a sort of last minute attention grabber as it were.

This was actually made in answer to someone else’s request for this functionality so maybe they could best answer this?

I’m just a little chuffed that I have successfully (so far) made my very first extension!! grin

Best wishes,

Mark

P.S. To anyone who may use this extension there may be a slight problem with the Logout extension if you log out from your main index page. I am currently looking into this.

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 05:31 PM   [ Ignore ]   [ # 17 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Aha!!! I have at you now!!!

Just noticed a good thing that the Login Redirect extension does!!!

When you login using the login form you don’t get the interim “You are now logged in” page and then get the re-direct to the page you were on.
Whilst some might like seeing this page to show that the user is now logged-in myself personally I don’t like seeing it and as on nearly all sites where a person can login I have usually got something on the site which will indicate to them that they are logged in anyway so this pretty much does away with the need to style one member template at least! grin

Just thought this might swing it for some people to use this!

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 05 December 2007 06:47 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  420
Joined  10-10-2004

Not sure if this is within the realm of possibility but I would love to see this used with membership groups in mind. I’d like to redirect member groups to different types of pages right after logging in. That would open up a whole bunch of possibilities for me and I bet for others.

Here’s an example of someone else who could use this type of functionality:

http://expressionengine.com/forums/viewthread/61430/

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65024 Total Logged-in Users: 40
Total Topics: 82111 Total Anonymous Users: 23
Total Replies: 441285 Total Guests: 183
Total Posts: 523396    
Members ( View Memberlist )