Redirect after Login on WordPress

后端 未结 13 3061
我寻月下人不归
我寻月下人不归 2020-12-04 11:26

I\'m creating a customized WordPress theme based on an existing site.

I want to use an alternate dashboard which I have created.

How can I have the user dire

13条回答
  •  遥遥无期
    2020-12-04 11:52

    The functions.php file doesn't have anything to do with login redirect, what you should be considering it's the wp-login.php file, you can actually change the entire login interface from there, and force users to redirect to your custom pages instead of the /wp-admin/ directory.

    Open the file with Notepad if using Windows or any text editor, Prese Ctrl + F (on window) Find "wp-admin/" and change it to the folder you want it to redirect to after login, still on the same file Press Ctrl + F, find "admin_url" and the change the file name, the default file name there is "profile.php"...after just save and give a try.

    if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) )
            $redirect_to = admin_url('profile.php');
        wp_safe_redirect($redirect_to);
        exit();
    

    Or you can use the "registration-login plugin" http://wordpress.org/extend/plugins/registration-login/, just simple edit the redirect urls and the links to where you want it to redirect after login, and you've got your very own custom profile.

提交回复
热议问题