Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Created January 21, 2012 16:51
Show Gist options
  • Save chrisguitarguy/1653264 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/1653264 to your computer and use it in GitHub Desktop.
Check WordPress usernames/passwords remote.
<?php
/*
Plugin Name: Authenticate Users Remotely
Author: Christopher Davis
Author URI: http://www.christopherguitar.net/
License: GPL2
*/
add_filter('xmlrpc_methods', 'wpse39662_add_login_method' );
/**
* Filters the XMLRPC methods to allow just checking the login/pass of
* a given users
*/
function wpse39662_add_login_method( $methods )
{
$methods['wpse39662.login'] = 'wpse39662_check_login';
return $methods;
}
function wpse39662_check_login( $args )
{
$username = $args[0];
$password = $args[1];
$user = wp_authenticate( $username, $password );
if( is_wp_error( $user ) )
{
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment