WordPress用户登陆后跳转到指定页面

WordPress用户登陆后跳转到指定页面

// redirect user after login not to go to profile, but elsewhere
// combination of http://www.shinephp.com/how-to-block-wordpress-admin-menu-item/ and
// http://www.strangework.com/2010/03/26/how-to-redirect-a-user-after-logging-into-wordpress/
if ( current_user_can( 'subscriber' ) ) {
    function so_redirect_after_login() {
        global $redirect_to;
        if ( !isset( $_GET['redirect_to'] ) ) {
            $redirect_to = ( get_option( 'siteurl' ) . '/wp-admin/rest-of-url' );
        }
    }
    add_action( 'login_form', 'so_redirect_after_login' );
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据