Skip to content

Instantly share code, notes, and snippets.

@Pushplaybang
Created July 1, 2013 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pushplaybang/5900116 to your computer and use it in GitHub Desktop.
Save Pushplaybang/5900116 to your computer and use it in GitHub Desktop.
WordPress Redirect to homepage after logout
<?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 . '&amp;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;
}
}
@Mohamed-Slimane
Copy link

Can i use it in my themes . I sell these themes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment