top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to redirect a Wordpress logout to custom URL?

0 votes
521 views

I want to send a user, logging out of WordPress, to a custom URL.
I used this below code into functions.php in my wordpress theme:

add_filter( 'logout_url', 'my_logout_url' );
    function my_logout_url( $url ) {
       return 'http://yourdomain.com/?a=logout';
    }

But it does not work.
How can I do this?
Many thanks in advance for your help or advice.

posted Aug 3, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

I know only 2 hooks when logout happen. This is logout_url and wp_logout. Usually, I use the wp_logout in the next way

function your_prefix_redirect() {
    wp_redirect('https://google.com/');
    die;
}
add_action('wp_logout', 'your_prefix_redirect', PHP_INT_MAX);

Use this code it will works.
Notice: I specified priority as maximum INT, because some other code may do anything else major while logout happen.

answer Aug 21, 2017 by Sanam
Similar Questions
0 votes

I want to create a separate custom 404 page for my wordpress site that when 404 error occurs then that page will be display. I create a 404 page but when I tried to test it, the 404 page of the root site appears. Can anybody help me?

0 votes

I just created a custom theme for my wordpress project inside my wp-content/themes/mycustomtheme, I added an index.php and a style.css file to the new theme but when I go to themes in my dashboard the newly created theme is not shown as an option. What else am I missing? Can anybody help me?
This is my style.css

/*
Theme Name: Start WordPress
Theme URI: http://wordpress.org/themes/startwordpress
Author: Me
Author URI: http://wordpress.org/
Description: The Start WordPress theme is my first custom theme.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: bootstrap, black, brown, orange, tan, white, yellow, light, one-
column, two-columns, right-sidebar, flexible-width, custom-header, 
custom-menu, editor-style, featured-images, microformats, post-
formats, rtl-language-support, sticky-post, translation-ready
Text Domain: startwordpress

This theme, like WordPress, is licensed under the GPL .
Use it to make something cool, have fun, and share what you've learned   
with others.
*/
0 votes

I am making a custom plugin for wordpress and i need to create a page in the admin menu. I already have a file called menu_list.php with the following code:

function jps_mail_list_page_entry() {
add_menu_page(
    __('JPS Mailing List'),
    'JPS Mailing List',
    'manage_options',
    'jpsNews_mailinglist',
    'jpsNews_mailing_list',
    'dashicons-email'
);
}
add_action('admin_menu', 'jps_mail_list_page_entry');

function jpsNews_mailing_list() {
    echo 'hello';
}

Now, in the plugin page i have this:

function jpsNews_activate_plugin() {
    include_once(plugin_dir_path(__FILE__).'pages/mailing-list.php');
}
register_activation_hook(__FILE__,'jpsNews_activate_plugin');

Its not working. How can i do it?

0 votes

I need to force HTTPS for my e-commerce site, but when I try, it goes into an HTTPS -> HTTP -> HTTPS loop. I reviewed my .htaccess, by couple of experienced techs but they found no issue on that. I checked my wp_config.php, and nothing there. Where else should I be looking? How would I hunt this down?

...