Top Left Text cha

Web & App Development

Here's some sample code on redirecting on login and logout.  It's incredible... I've found multiple answers on this function in both the WordPress codex and Stack Exchange.  MOST DO NOT WORK.  Which is typical inconsistent and misinforming WordPress information on the web.

function my_login_redirect( $redirect_to, $request, $user ) {
    $redirect_to =  '/items/'; return $redirect_to;

}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

function redirect_after_logout() {
    if (!current_user_can('manage_options')) {

        $url = '/';
    } else {

        $url = 'wp-login.php?loggedout=true';
    }
    $redirect_url = home_url( $url );
    wp_safe_redirect( $redirect_url );
    exit;

}
add_action('wp_logout', 'redirect_after_logout');

Add comment


Security code
Refresh

  • No comments found

Leave your comments

Post comment as a guest

0
Your comments are subjected to administrator's moderation.
X