EllisLab text mark
Advanced Search
1 of 5
1
   
New Extension Completed!! - Logout Redirect
Posted: 07 December 2007 05:36 PM   [ Ignore ]
Avatar
Joined: 2006-04-15
12649 posts

Hiya,

You may have seen my previous post regarding this. I thought I would post this in a new thread though so that it will all be fresh.

I have now finished the creation of my Logout Redirect extension which is actually an extension and a Plugin. Usage is exceptionally simple and is outlined below :


Plugin code for use in templates

{if logged_in}
{exp
:logout_redirect url="http://www.yahoo.com" text="Get Me Out Now" styles="class='logout-link-class' title='Logout Link'"}
{
/if} 

This will create the standard ExpressionEngine log-out link on any template that you place it on and in conjunction with the extension will log the user out and then re-direct them to the url as specified above.

Installation Instructions

1 Download the Logout Redirect package from the bottom of this post.
2 Copy the ext_logout_redirect.php file to your system->extensions folder.
3 Copy the pi.logout_redirect.php file to your system->plugins folder.
4 Copy the lang.logout_redirect.php file to your system->language->english folder.

N.B. You may have a different name for your system folder as you may have changed this upon installation of your ExpressionEngine system.

5 Log in to the Admin section of your site and install the Logout Redirect extension.
6 Place the Plugin code (shown above) into one of your templates.
7 Try logging out on the user side. You should be first of all logged-out and then re-directed to the url that you specified!

N.B. You must use the {if logged_in} code and surround the plugin with this.

Also with the plugin code you can do the following kind of thing :

{if logged_in}
{if member_group 
== "1"}
{exp
:logout_redirect url="http://www.yahoo.com" text="Get Me Out Of Here" styles="class='logout' title='Logout'"}
{
/if}
{
/if} 

This can mean that you can place loads of these on a page and have people redirected to different places on logout depending upon their member group.
Enjoy!! grin

I will be adding to this in the future depending on any feature requests that anyone thinks up and if I can actually figure them out in the first place as this is my first extension that I have created and I am quite proud of it. I’m pretty sure that my code is good but please be aware that there are no warranties with this and you should use it at your own risk. That said I have tested this out many many times and it seems to work very well so hopefully it shouldn’t cause any problems but do remember to backup first just in case.

Hope someone finds it useful.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 07 December 2007 05:44 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2004-10-10
265 posts

This sounds great! Will you be adding the same functionality for logging in? smile

 Signature 

Twitter: @RobQuigley

 
Posted: 07 December 2007 05:59 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Darn you beat me to it! grin

I am in the process of making this one too. Thought I would let people play with this for a while first though and gauge their views on it and any feature requests and see if anyone has anything they would like to see in the Login Extension. Any ideas?

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 07 December 2007 06:04 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2004-10-10
265 posts

Ok, sounds good. I’m waiting more for the login side of this but excited that half of this is accomplished.

 Signature 

Twitter: @RobQuigley

 
Posted: 07 December 2007 06:07 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Oops meant to mention to anyone reading this!

You must specify the full url that you wish to re-direct to with the plugin such as :

url="http://www.yahoo.com" 

you cannot do this :

url="www.yahoo.com" 

or this will not work. I am trying to find a way around this at the moment. Darn I knew there would be one thing I would forget to say in the usage instructions!! grin
Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 07 December 2007 06:09 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

I am also thinking that I might change this so that all the plugin does is lets the extension know where it is that you would like to re-direct to and not create the actual log-out link as you could just use the standard {path=LOGOUT} link and style it however you see fit.

This would also bring a few lines out of my plugin too which would make it a little leaner!! grin

Will think about this some more and see what people think too.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 08 December 2007 04:24 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-09-20
530 posts

Very helpful Mark!

 
Posted: 08 December 2007 06:55 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hi Jesse,

Thanks!! I’m thinking that the Login Redirect extension / plugin that I am trying to make at the moment will be the more needed one for people though. Having a few problems with it at the moment though. The general idea is there I’m just getting into the nitty gritty of the coding for it now.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 08 December 2007 07:20 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2006-09-20
530 posts

Mark,
Just out of curiosity - Can’t you already do a login redirect with the member:login_form tag?

Jesse

 
Posted: 08 December 2007 07:49 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hi Jesse,

Yes you can but I want to make this so that people can just place :

{exp:login_redirect url="site/contact/" text="Log Me In Now!!" styles="class='log-me-in'"

this would then create the standard login link but when they have logged in allow them to be redirected to anywhere they want instead of just having the one redirect location hard-coded into the login form. I suppose you may be able to get around that problem by using a global variable and utilising that from within the Login Form but haven’t tried that yet. Also if I can get it to work it would make it easier (I think! grin ) for people to log in to different pages from different pages so say for instance someone is on a site/about page they could be re-directed to saysite/legal upon logging in but someone who was at site/legal could (as they have already seen that page) be re-directed somewhere else instead.

Really just a bit more power I suppose but yes the Login form does have a re-direct and I guess you may be able to use globals with that. Will have to look into that.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 08 December 2007 08:05 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2006-09-20
530 posts

I see the difference.  Good luck with it!

 
Posted: 08 December 2007 08:18 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

I need it. A few teething problems at the moment!! grin

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 08 December 2007 10:53 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2007-03-30
111 posts

Mark,

What a response to what I thought was simple question. I’m very impressed!!

I gave it run this evening and well of course I had some issues beyond my realm of knowledge.

I set it up on my page:

{if logged_in}
{exp
:logout_redirect url="login/0_0_secureLogin" text="LOG-OUT!!" styles="class='log' title='Logout Link'"}
{
/if} 

and when I try to few the page is on I get this error:

MySQL ERROR:

Error Number: 1146

Description: Table ‘neednotsay_com_-_expressthis.exp_logout_redirect_url’ doesn’t exist

Query: DELETE FROM exp_logout_redirect_url WHERE member_id = ‘1’

Any thoughts?
Chris

 
Posted: 09 December 2007 07:40 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hi Chris,

Do you have the Logout Redirect extension enabled? If not then you will see that error as the extension (when first enabled) creates that table (exp_logout_redirect_url) and that is used within the plugin. If you don’t enable the extension then that problem will occur.

If you go to :

Admin->Utilities->Extensions Manager

First of all check that the button at the top right of that section says ‘Disable Extensions?’. If it says this then that is correct as it means that your extensions are turned on and you don’t need to do anything there. If it says‘Enable Extensions?’ then you need to click on it and follow the on screen instructions to first of all enable them.

Once you have extensions enabled or if they already are then check that the Logout Redirect extension is enabled. If not then enable it and it will create the necessary table for you. You should then be able to re-visit the page where you have placed the plugin code into and it should work fine.

Hope that helps.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 09 December 2007 12:34 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Okay for all those who are following all of this I now have the Login Redirect extension / plugin working!!!

Please see this post and definitely read the disclaimer before using this on a live site!! grin

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

 
Posted: 09 December 2007 01:04 PM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2007-03-30
111 posts

Mark,

Any thoughts about this.

Notice: Undefined variable: default_settings in /home/virtual/site179/fst/var/www/html/expressionEngine/system/extensions/ext.login_redirect.php on line 51

Warning: Cannot modify header information - headers already sent by (output started at /home/virtual/site179/fst/var/www/html/expressionEngine/system/extensions/ext.login_redirect.php:51) in /home/virtual/site179/fst/var/www/html/expressionEngine/system/core/core.functions.php on line 296


I cleared out the old versions and reinstalled them then went to extension manager and enabled it when it asked to confirm
my action I got the above message on a white screen.

Your thoughts,
Chris

 
1 of 5
1