我修改了@Patriot代码。
我能够通过以下代码实现所需的功能:我将此代码添加到\\wp-includes\\functions.php 在文件的和处。
它不像我所希望的那么干净,但它很管用。
如果有人发现此方法存在任何可能的问题,请通知我们
add_action(\'init\', function() {
if ($GLOBALS[\'pagenow\'] === \'wp-login.php\' && is_user_logged_in()) {
$defLoginPageActions = array(
//\'confirm_admin_email\',
//\'postpass\',
\'logout\',
//\'lostpassword\',
//\'retrievepassword\',
//\'resetpass\',
//\'rp\',
//\'register\',
//\'checkemail\',
//\'confirmaction\',
//\'login\',
WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED,
);
$loginPageAction = isset( $_REQUEST[\'action\'] ) ? $_REQUEST[\'action\'] : \'\';
if(!in_array( $loginPageAction, $defLoginPageActions)){
wp_redirect(home_url());
exit;
}
}
});