<?php/*Plugin Name: Update Remote PasswordVersion: 1.1.1Description: Updates the password on remote site when user changes his password on this one.Author: Elvis MoralesAuthor URI: https://twitter.com/n3rdh4ck3rPlugin URI: https://bitbucket.org/grantcardone/update-remote-passwordText Domain: update-remote-password*/if(!defined('ABSPATH')){exit;// Exit if accessed directly}define('REMOTE_SITE','http://witnation.staging.wpengine.com/');define('API_BASE','cardoneapi');define('USER_UPDATE_PASSWORD','user/update_password');//Action when reset password is gonna be doneadd_action('password_reset','remote_password_reset',10,2);functionremote_password_reset($user,$new_pass){$params=array('user_login'=>urlencode($user->user_login),'user_pass'=>urlencode($new_pass));$api_url=REMOTE_SITE;if(substr($api_url,-1)!='/')$api_url.='/';$api_url.=API_BASE;if(substr($api_url,-1)!='/')$api_url.='/';// Generate the URL to update user password$url=$api_url.USER_UPDATE_PASSWORD;$url=add_query_arg($params,esc_url_raw($url));$update_password_response=wp_remote_get(esc_url_raw($url));$decoded_response=json_decode(wp_remote_retrieve_body($update_password_response));if(is_wp_error($update_password_response))error_log("WP ERROR NOTICE: ".$update_password_response->get_error_message());elseif($decoded_response->status=='error')error_log("ERROR NOTICE: ".$decoded_response->error);elseerror_log("OK NOTICE: ".$decoded_response->message);}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.