We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

New Extension Completed!! - Logout Redirect

Development and Programming

Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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!! 😊

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

       
Rob Quigley's avatar
Rob Quigley
236 posts
17 years ago
Rob Quigley's avatar Rob Quigley

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Darn you beat me to it! 😊

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

       
Rob Quigley's avatar
Rob Quigley
236 posts
17 years ago
Rob Quigley's avatar Rob Quigley

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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!! 😊 Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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!! 😊

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

Best wishes,

Mark

       
jschutt's avatar
jschutt
452 posts
17 years ago
jschutt's avatar jschutt

Very helpful Mark!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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

       
jschutt's avatar
jschutt
452 posts
17 years ago
jschutt's avatar jschutt

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

Jesse

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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! 😊 ) 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

       
jschutt's avatar
jschutt
452 posts
17 years ago
jschutt's avatar jschutt

I see the difference. Good luck with it!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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

Best wishes,

Mark

       
swenke's avatar
swenke
70 posts
17 years ago
swenke's avatar swenke

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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!! 😊

Best wishes,

Mark

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.