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());
}
}
왜이 작업을 수행하려고합니까? –
숨겨진 수퍼 유저를 갖고 싶지만 다른 관리자에게는 수퍼 유저 패스를 변경하거나이 사용자를 볼 수있는 권한이 없습니다. – Mario