2011-10-08 3 views
-1

나는 사용 후 로그인 한 후 다른 사이트로 리디렉션하려고하는 WordPress 사이트가 있습니다. 어떻게 워드 프레스에서 이것을 할 수 있습니까? PHP 헤더 기능 (header ("Location : http://www.somesite.com"))을 설정하지 않았다면 헤더가 이미 header.php 파일에 설정되어 있다고합니다. 그래서 기본적으로 어떻게 WordPress를 통해 리디렉션합니까?어떻게 WordPress 사이트에서 리디렉션합니까?

워드 프레스는 워드 프레스 사이트에서 안전하게 리디렉션하는 데 사용할 수있는 직접적인 직접 기능을 갖고 있습니까? 그 밖의 무엇을해야할지 모르겠으니 도와주세요. 고마워요.

+0

어디에서 코드를 리디렉션합니까? (에서와 같이, 어떤 시점에서 .. 페이지 템플릿 내부 등) – Ben

답변

3

, 당신은 wp_redirect을 사용할 수 있습니다 희망 : 로그인 페이지의 URL에 redirect_to 쿼리 문자열 값이있는 경우

function my_allowed_redirect_hosts($allowed) { 
    $allowed[] = 'other.com'; 
    $allowed[] = 'www.other.com'; 
    return $allowed; 
} 
add_filter('allowed_redirect_hosts','my_allowed_redirect_hosts'); 

일반적으로,이 인증 한 후 해당 위치로 리디렉션을 시도합니다. 당신이 할 수있는, 다른 사이트로 아웃 및 redirectng 로그를 들어

function custom_login_redirect() { 
    return 'http://www.other.com/Home/Authenticated'; 
} 
add_filter('login_redirect', 'custom_login_redirect'); 

: 로그인에 관계없이 redirect_to 쿼리 문자열 값의 사용자를 리디렉션 곳

functions.php에 추가 (당신의 가치와 위치를 교체)를 다시 변경하려면 다음과 같이 사용하십시오 :

<a href="<?=wp_logout_url("http://other.com/Account/LogOff")?>">Log Off</a> 
0

은 (당신이 allowed_hosts 목록에 리디렉션 할 위치)이 하나

//chage the redirection url for login 
add_filter('login_redirect','my_redirect_to_my_site',100,3); 
function my_redirect_to_my_site($redirect_to_calculated,$redirect_url_specified,$user){ 
    return "http://google.com";//where you want to redirect ,change with that 

} 


//add the domain to allowed hosts list for redirection 
add_filter('allowed_redirect_hosts','my_allowed_redirect_hosts'); 
function my_allowed_redirect_hosts($allowed_hosts){ 
$allowed_hosts[]='google.com'; //add the other domain to allowed hosts where to redirect 
return $allowed_hosts; 
} 

가 호스트 이름을 추가 할 수 있는지 확인하십시오. 당신은이 코드를 당신의 테마의 functiions.php에 넣을 수 있으며, 로그인시 사용자를 리디렉션 할 것입니다. (당신의 값으로 교체 '기타')을 functions.php에 다음을 추가,

<?php 
wp_redirect($location, $status); 
exit; 
?> 

다른 사이트로 리디렉션을 허용하려면 (Function Reference/wp_redirect 참조)하는 데 도움이 : 일반 페이지에서

관련 문제