{"id":5417401,"date":"2014-10-24T03:07:25","date_gmt":"2014-10-24T03:07:25","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/fixed-plugin\/"},"modified":"2016-08-22T03:46:05","modified_gmt":"2016-08-22T03:46:05","slug":"fixed-plugin","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/fixed-plugin\/","title":{"rendered":"Fixed Plugin"},"content":{"rendered":"<p>I used to use this plugin frequently to troubleshoot member issues on a large membership site built by https:\/\/www.visualizedigital.com<\/p>\n<p>This plugin does not work since they deprecated get_userdatabylogin. Here is the revised source to make the plugin work again:<\/p>\n<pre><code>&lt;?php\n\/*\n* Plugin Name: Skeleton Key\n* Plugin URI: http:\/\/github.com\/sant0sk1\/wp-skeleton-key\n* Description: Gives administrators a skeleton key (their own password) to login as any user they&#039;d like.\n* Author: Jerod Santo\n* Author URI: http:\/\/jerodsanto.net\n* Version: 1.1.1\n* *\/\n\n\/\/ HOOK ME UP\nadd_filter(&#039;authenticate&#039;, &#039;authenticate_with_skeleton_key&#039;, 10, 3);\n\nfunction authenticate_with_skeleton_key($user, $username, $password) {\n  if (is_a($user, &#039;WP_User&#039;)) { return $user; }\n\n  if (!empty($username) &amp;&amp; !empty($password)) {\n    \/\/ We expect to receive the username in this format: admin_username+username\n    list($admin_name, $user_name) = explode(&#039;+&#039;, $username);\n\n    if(!empty($admin_name) &amp;&amp; !empty($user_name) &amp;&amp; $admin_name != $user_name){\n      $userdata  = get_user_by(&#039;login&#039;,$user_name);\n      $admindata = get_user_by(&#039;login&#039;,$admin_name);\n\n      $admin = new WP_User($admindata-&gt;ID);\n\n      if( $admin-&gt;has_cap(&#039;level_10&#039;) &amp;&amp; $userdata ){ \/\/ Make sure the first username was an admin\n        if (wp_check_password($password, $admindata-&gt;user_pass, $admindata-&gt;ID)) {\n          return new WP_User($userdata-&gt;ID); \/\/ Return the second username as the logged in user.\n        }\n      }\n    }\n  }\n  return new WP_Error;\n}\n?&gt;<\/code><\/pre>\n<p>https:\/\/wordpress.org\/plugins\/skeleton-key\/<\/p>\n","protected":false},"template":"","class_list":["post-5417401","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5417401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5417401\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5417401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}