密码重置后,如何将站点访问者重定向到我站点的主页

时间:2016-12-31 20:38:35

标签: php wordpress change-password

我希望在重置密码后,我的网站访问者会被重定向到我网站的主页。在网上研究了这个之后,我想我可以通过在我的活动主题文件夹中插入我的functions.php末尾的粘贴框中的代码来实现这一点。但是当我访问我的网站时,我收到以下错误消息。

  

解析错误:语法错误,第116行/home/pyepez/public_html/wp-content/themes/Builder-Everett-Custom/functions.php中的意外文件结尾

     

警告:无法修改标头信息 - 已在/ home / pyepez / public_html中发送的标头(输出从/home/pyepez/public_html/wp-content/themes/Builder-Everett-Custom/functions.php:116开始)第153行/wp-content/plugins/ithemes-exchange/lib/sessions/db_session_manager/class-db-session.php

关于可能出现什么问题的任何建议?请帮忙,

Patrick Yepez

add_action( "password_reset", "rngs_password_reset", 10, 2 );

/**
 * Implement "password_reset" for RNGS
 *
 * After a password reset has been performed we want the Log in link to redirect the user to the home url.
 * When we see this action being run we know that we should be filtering "login_url" to add the redirect the home page.
 * We don't filter "login_url" any other time. 
 *
 * @param WP_User $user - the user object
 * @param string $new_pass - the new password
 *  
 */
function rngs_password_reset( $user, $new_pass ) {
  add_filter( "login_url", "rngs_login_url", 10, 2 );
}

/**
 *  Implement "login_url" filter for RNGS
 *
 * Redirect the user to the home page after logging in
 *
 * @TODO - make this an option field that controls where the logged in user goes
 * @TODO - dependent upon role?
 * 
 * @param string $login_url - the original login_url which is not expected to include "redirect_to" or "reauth"
 * @param string $redirect - expected to be null/blank
 */
function rngs_login_url( $login_url, $redirect ) {
  $home_redirect = home_url();
  $login_url = add_query_arg('redirect_to', urlencode( $home_redirect ), $login_url);

0 个答案:

没有答案