2017-03-13 139 views

回答

1

您可以使用user_register鉤子;它在任何用戶註冊或添加到數據庫後調用。

下面是代碼:

add_action('user_register', 'wh_redirectAfterRegistration', 10, 1); 

function wh_redirectAfterRegistration($user_id) 
{ 
    if (empty($user_id)) 
     return; 

    $user = wp_get_current_user(); 
    $curr_roles = $user->roles; 
    $page_id = 70; //<-- Replace with YOUR PAGE ID 

    //if logged in user is admin 
    if (in_array('administrator', $curr_roles)) 
    { 
     wp_redirect(get_permalink($page_id)); 
     exit(); 
    } 
} 

代碼放在您的活動子主題(或主題)的function.php文件。或者也可以在任何插件php文件中使用。
代碼已經過測試和工作。

希望這會有所幫助!

+0

太棒了!這樣可行! –

相關問題