2013-05-26 3 views
-1

WordPress에 가상 사용자를 만들고 싶습니다. 사용자 이름과 비밀번호가 데이터베이스 또는 대시 보드에 존재하지 않지만 로그인 한 경우 사용자 이름과 비밀번호를 인식하고 WP를 normaly로 이동해야합니까? 사용자 이름과 암호는 PHP 코드로 일부 파일로 인코딩됩니다 (플러그인 가능). 가능하거나 사막에서 검색하고 있습니까?WordPress에 가상 사용자를 만들려면 어떻게해야합니까?

지금까지 : 나는 username = example 및 password = asdfgh로 로그인 할 수 있으며 사용자 ID = 1 인 로그인입니다. 어떻게 든 가상 사용자이지만 로그인 프로세스는 데이터베이스에 실제 사용자를 포함합니다. 감사.

<?php 
/*Plugin Name: A Login 
*/ 

function alogin_virtual_login($username,$password) { 
    if (isset($username) && isset($password)) 
     if (($username == "example") && ($password == "asdfgh")) 
      return true; 

    return false; 
} 
// http://www.blackbam.at/blackbams-blog/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/ 
// this action is executed just before the invocation of the WordPress authentication process 
add_action('wp_authenticate','alogin_authentication'); 
function alogin_authentication() { 
    $username=$_POST['log']; 
    $password=$_POST['pwd']; 

    // try to log into the external service or database with username and password 
    $ext_auth = alogin_virtual_login($username,$password); 

    // if external authentication was successful 
    if($ext_auth) { 
    // this will actually make the user authenticated as soon as the cookie is in the browser 
     wp_set_auth_cookie(1); 

     // you can redirect the authenticated user to the "logged-in-page" 
     header("Location:".get_page_link()); 
    } 
} 
+0

왜이 작업을 수행하려고합니까? –

+0

숨겨진 수퍼 유저를 갖고 싶지만 다른 관리자에게는 수퍼 유저 패스를 변경하거나이 사용자를 볼 수있는 권한이 없습니다. – Mario

답변

1

그것은 단지 http://codex.wordpress.org/Function_Reference/current_user_can처럼

워드 프레스 사용자 주위에 많은 기능을 제공합니다 ... 로그인에 대한 단지 예를 들기 아니다.

따라서 인식하려면 사용자가 반드시 데이터베이스에 있어야합니다.

나는 오히려 표시된 사용자로부터 그 사용자를 지키기위한 접근 방법을 찾고자합니다.

+0

이것이 내 첫 번째 옵션 이었지만 대시 보드의 사용자 목록에서 숨겨진 사용자는 테이블 위에서 sistem의 번호를 매기는 것이 아니라 목록에서만 숨겨졌습니다. – Mario

관련 문제