欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WordPress用戶登錄登出后重定向到指定頁(yè)面的實(shí)現(xiàn)方法

  發(fā)布時(shí)間:2016-08-23 21:46:41   作者:佚名   我要評(píng)論
這篇文章主要介紹了WordPress用戶登錄登出后重定向到指定頁(yè)面的實(shí)現(xiàn)方法,需要的朋友可以參考下
這篇文章將向您展示W(wǎng)ordPress用戶登錄后如何重定向到指定頁(yè)面或者文章的技巧。

一、重定向到網(wǎng)站管理面板。
將以下代碼添加到您的當(dāng)前主題的 functions.php 文件中:
PHP Code復(fù)制內(nèi)容到剪貼板
  1.  function soi_login_redirect($redirect_to$request$user)   
  2. {   
  3.     return (is_array($user->roles) && in_array('administrator'$user->roles)) ? admin_url() : site_url();   
  4. }   
  5. add_filter('login_redirect''soi_login_redirect', 10, 3);  

二、重定向到指定頁(yè)面或者文章
您還可以將用戶重定向到特定頁(yè)面,代碼如下:
PHP Code復(fù)制內(nèi)容到剪貼板
  1.  function login_redirect( $redirect_to$request$user ){   
  2.     return home_url('custom-page');   
  3. }   
  4. add_filter( 'login_redirect''login_redirect', 10, 3 );  
修改代碼中的custom-page為某個(gè)頁(yè)面或者文章的鏈接(注:不包括站點(diǎn)域名),如果刪除custom-page會(huì)直接跳轉(zhuǎn)到站點(diǎn)首頁(yè)。

三、自定義登出之后的重定向鏈接

PHP Code復(fù)制內(nèi)容到剪貼板
  1.  add_action('wp_logout','auto_redirect_after_logout');      
  2. function auto_redirect_after_logout(){      
  3.   wp_redirect( home_url() );      
  4.   exit();      
  5. }  

以上即登出后跳轉(zhuǎn)到網(wǎng)站首頁(yè)

相關(guān)文章

最新評(píng)論