Created
July 1, 2013 11:34
-
-
Save Pushplaybang/5900116 to your computer and use it in GitHub Desktop.
WordPress Redirect to homepage after logout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Redirect to homepage after logout | |
* @version 0.1 | |
*/ | |
/* | |
Plugin Name: Redirect to homepage after logout | |
Plugin URI: http://daankortenbach.nl/wordpress/redirect-to-homepage-after-logout/ | |
Description: Redirects the user to the homepage after logout | |
Author: Daan Kortenbach | |
Version: 0.1 | |
Author URI: http://krtnb.ch/ | |
*/ | |
add_filter('logout_url', 'dmk_logout_redirect_url', 10, 2); | |
/** | |
* Adds a redirect url to the homepage to $logouturl | |
* | |
* @author Daan Kortenbach | |
* @param string $logouturl Existing logouturl | |
* @return string $logouturl Amended with redirect url | |
*/ | |
function dmk_logout_redirect_url( $logouturl ) { | |
return $logouturl . '&redirect_to=' . urlencode( get_option( 'siteurl' ) ); | |
} | |
add_action( 'init', 'dmk_loggedout_redirect' ); | |
/** | |
* Redirects if loggedout is true in case a custom logouturl is used. | |
* | |
* @author Daan Kortenbach | |
*/ | |
function dmk_loggedout_redirect() { | |
if( $_GET['loggedout'] == 'true' ) { | |
wp_redirect( get_option( 'siteurl' ) ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can i use it in my themes . I sell these themes