1 of 4
1
New Extension Completed!! - Logout Redirect
Posted: 07 December 2007 02:36 PM   [ Ignore ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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

File Attachments
ext_logout_redirect_v1.2.zip  (File Size: 9KB - Downloads: 383)
 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 07 December 2007 02:44 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  462
Joined  10-10-2004

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

Profile
 
 
Posted: 07 December 2007 02:59 PM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 07 December 2007 03:04 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  462
Joined  10-10-2004

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

Profile
 
 
Posted: 07 December 2007 03:07 PM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 07 December 2007 03:09 PM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 08 December 2007 01:24 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  418
Joined  09-20-2006

Very helpful Mark!

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 08 December 2007 03:55 PM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 08 December 2007 04:20 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  418
Joined  09-20-2006

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

Jesse

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 08 December 2007 04:49 PM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 08 December 2007 05:05 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  418
Joined  09-20-2006

I see the difference.  Good luck with it!

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 08 December 2007 05:18 PM   [ Ignore ]   [ # 11 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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

Best wishes,

Mark

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 08 December 2007 07:53 PM   [ Ignore ]   [ # 12 ]  
Grad Student
Rank
Total Posts:  85
Joined  03-30-2007

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

Profile
 
 
Posted: 09 December 2007 04:40 AM   [ Ignore ]   [ # 13 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 09 December 2007 09:34 AM   [ Ignore ]   [ # 14 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

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
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 09 December 2007 10:04 AM   [ Ignore ]   [ # 15 ]  
Grad Student
Rank
Total Posts:  85
Joined  03-30-2007

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

Profile
 
 
Posted: 09 December 2007 10:14 AM   [ Ignore ]   [ # 16 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

Hi Chris,

Sorry about that. Are you using the Logout Redirect extension that I have made or the Login Redirect extension?
I only ask as what you have shown above is an error with exp.login_redirect.php shown in it. The Logout Redirect extension has nothing in it that would spit out that error.

The easiest way to start again, although this involves messing with the database is to delete any rows from exp_extensions that contain Logout_redirect if it is indeed the Logout Redirect extension that you are trying to use?

Also delete the table exp_logout_redirect_url. You should then be able to try again.

Still wondering why you are getting the error message that you have there though as that says ext.login_redirect.php and shouldn’t be saying that if you are trying the Logout Redirect extension.

Hope that helps.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 09 December 2007 10:29 AM   [ Ignore ]   [ # 17 ]  
Grad Student
Rank
Total Posts:  85
Joined  03-30-2007

Mark,

No need to apologize I’m just happy that their are people out in the EE community that are willing to help like this. I can only hope as my experience grows that I can begin to give back.

I figured out what I had going on, I got mixed up between Logout and Login, just got caught up doing and didn’t read.

What do think about the possibilities of wrapping the code below with your extension and making it work. 

<span class="log"><a href="#">LOG-OUT</a></span>

Your thoughts,
Chris

Profile
 
 
Posted: 09 December 2007 10:35 AM   [ Ignore ]   [ # 18 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

Hi Chris,

No problem at all. All this is really new to me too (the creating extensions I mean) and I went through tons and tons of changes until this worked. At least I hope it all works well! grin

What exactly do you want your logout link to look like? Do you just want to wrap a span class around it. If so then I think this would probably work :

<span class="log">
{exp:logout_redirect url="http://www.yahoo.com" text="Log Out To Yahoo" styles="class='main'"}
</span>

The plugin is at the moment just a single tag and not a tag pair so in itself it can’t be wrapped around anything but the code above should get what you need if I am understanding correctly.

Hope that helps.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
   
1 of 4
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: 77565 Total Logged-in Users: 35
Total Topics: 101555 Total Anonymous Users: 19
Total Replies: 544399 Total Guests: 274
Total Posts: 645954    
Members ( View Memberlist )
Newest Members:  semperjrawhallshiusbozzlynobluffkatiejameshsmith101dddougalcampinggreaterphoenix54