我不是很精通php。我发现功能,我可以在WP头使用-然后从"小绿框"在头用户停留在页面上,他试图登录时登录。这是我的网页与WP: http://www.computers-and-control.com/service/manuals/
现在我有其他的问题,我复制文件/wp-login.php到/wp-logincc.php这个新文件用于登录在我的模板wp-下载管理器-当点击文件-需要登录之前下载比使用/wp-logincc.php函数登录。
问题是,从wp-logincc.php登录后,我被重定向到"仪表板/管理面板"-我会回到我来自的子页面。我使用不同的子页面下载文件与所需的登录,总是需要回到这个我来自。
我尝试在我的wp-logincc.php代码:
<?php
/**
* WordPress User Page
*
* Handles authentication, registering, resetting passwords, forgot password,
* and other user handling.
*
* @package WordPress
*/
/** Make sure that the WordPress bootstrap has run before continuing. */
require( dirname(__FILE__) . '/wp-load.php' );
// dankam tu cos ewentualnie zmienic ---- Redirect to https login if forced to use SSL
$dankam_aaa = apply_filters( 'fromwhereyoucame', $fromwhereyoucame );
function fromwhereyoucame( $link ) {
$currenturl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if ( !is_user_logged_in() )
$link = str_replace( '">', '?redirect_to=' . urlencode( $currenturl ) . '">', $link );
else
$link = str_replace( '">', '&redirect_to=' . urlencode( $currenturl ) . '">', $link );
return $link;
}
if ( force_ssl_admin() && ! is_ssl() && $dankam_aaa ) {
if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
exit();
} else {
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
exit();
}
}
但是在/wp-logincc.php
(但是这个封闭的函数"function fromwhereyoucame"在"green box"中有效)
请帮忙修改wp-logincc.php
为什么不使用插件https://wordpress.org/plugins/theme-my-login/
在登录同一页面或仪表板重定向后设置。
或要在登录后实现此重定向,请将以下代码添加到主题的functions.php文件中:
> if ( (isset($_GET['action']) && $_GET['action'] != 'logout') ||
> (isset($_POST['login_location']) && !empty($_POST['login_location']))
> ) {
> add_filter('login_redirect', 'my_login_redirect', 10, 3);
> function my_login_redirect() {
> $location = $_SERVER['HTTP_REFERER'];
> wp_safe_redirect($location);
> exit();
> } }
通过在核心
中编辑来进行更改的另一种解决方案wp-login.php
第424 - 426行…
} else {$redirect_to = admin_url();}
改变…
{$redirect_to = $_SERVER[HTTP_REFERER];}