{"id":193235,"date":"2024-05-24T08:49:22","date_gmt":"2024-05-24T08:49:22","guid":{"rendered":"https:\/\/it.wordpress.org\/plugins\/same-user-credentials\/"},"modified":"2024-05-24T13:38:21","modified_gmt":"2024-05-24T13:38:21","slug":"same-user-credentials","status":"publish","type":"plugin","link":"https:\/\/twd.wordpress.org\/plugins\/same-user-credentials\/","author":18756751,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0.0","stable_tag":"1.0.0","tested":"6.5.8","requires":"6.0","requires_php":"7.4","requires_plugins":null,"header_name":"Same user credentials","header_author":"Giulio Pandolfelli","header_description":"Share login credentials between multiple sites","assets_banners_color":"","last_updated":"2024-05-24 13:38:21","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":0,"author_block_rating":0,"active_installs":10,"downloads":1405,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation"],"tags":{"1.0.0":{"tag":"1.0.0","author":"giuliopanda","date":"2024-05-24 13:38:21"}},"upgrade_notice":[],"ratings":[],"assets_icons":{"icon-128x128.jpg":{"filename":"icon-128x128.jpg","revision":3091975,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.jpg":{"filename":"icon-256x256.jpg","revision":3091975,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[710,160886,177137,228063],"plugin_category":[],"plugin_contributors":[200465],"plugin_business_model":[],"class_list":["post-193235","plugin","type-plugin","status-publish","hentry","plugin_tags-authentication","plugin_tags-multisite-user","plugin_tags-share-login","plugin_tags-users-sync","plugin_contributors-giuliopanda","plugin_committers-giuliopanda"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/same-user-credentials\/assets\/icon-128x128.jpg?rev=3091975","icon_2x":"https:\/\/ps.w.org\/same-user-credentials\/assets\/icon-256x256.jpg?rev=3091975","generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>The plugin synchronizes users with a main site, allowing you to access all sites where the plugin is installed with the same credentials.<\/p>\n\n<ul>\n<li>One website must be configured as a server, while the other sites must be configured as clients.<\/li>\n<li>Users registered on the server site can now access client sites using the same login credentials.<\/li>\n<li>In the client site, if the user does not exist, a new user is created with the data coming from the server. You can customize the data to be saved on the client site through several hooks described later.<\/li>\n<li>If the user already exists (checks the username) then the plugin updates the user information.<\/li>\n<li><p>If the user exists on the client, but not on the server, the plugin blocks access by changing the password to the user saved on the client.<\/p><\/li>\n<li><p>For security reasons the plugin does not synchronize administrators.<\/p><\/li>\n<li>When you click on recover password from a client site you are redirected to the server site to recover your password. Once you have recovered the password you return to the client site login. When you try to register a user from a client site you are redirected to the server site to register the user.<\/li>\n<li>If a user has logged in to a client site and logs in again through cookies, then without logging in again the system updates the user data with the server data once a day. If the user no longer exists on the server, he or she is logged out of the client site.<\/li>\n<li>Client users are never deleted even if they are no longer present on the server.<\/li>\n<li>Be careful if a user already exists on the client with the same email, but different user login, the user is not logged in.<\/li>\n<\/ul>\n\n<h3>Security<\/h3>\n\n<p>Communications take place via APIs protected through an encrypted token system. Usernames and passwords are never passed in clear text or through a basic authentication system.<\/p>\n\n<p>Synchronizing administrators is not allowed, administrators must be managed locally.<\/p>\n\n<p>Some user metadata is not passed because it is specific to the configuration of each individual site.<\/p>\n\n<h3>Logs<\/h3>\n\n<p>All operations are logged both on the client site and on the server.<\/p>\n\n<h3>Customizations<\/h3>\n\n<p>By default the plugin synchronizes all user except administrators. By default The plugin synchronizes all user data, roles, and metadata.<\/p>\n\n<p>However, you can customize who and what to sync through many specially created filters and hooks.<\/p>\n\n<p>First you may want to choose which users you want to sync and which you don't.   You can choose which user roles you want to sync. This way if the user has a certain role it will be synchronized, otherwise not. You can do this through the sucw-roles-exclude-all-sync-except filter placed in the client site.<\/p>\n\n<p><strong>apply_filters('sucw-roles-exclude-all-sync-except', ['subscriber']);<\/strong>\n<em>(CLIENT)<\/em> Excludes all roles from synchronization except those specified\nThis overrides the filter 'sucw-roles-to-exclude-sync'!\nparam array $array_exclude the list of default roles ['subscriber']\nsince 1.0.0<\/p>\n\n<p>Otherwise you can choose to sync all users except those who have a certain role.<\/p>\n\n<p><strong>apply_filters('sucw-roles-to-exclude-sync', ['administrator'])<\/strong>\n<em>(CLIENT)<\/em> These are the roles that do not need to synchronize\nIf active The filter 'sucw-roles-exclude-all-sync-except' will be ignored\nparam array $array_exclude the list of default roles ['administrator']\nsince 1.0.0<\/p>\n\n<p>The same role configuration entered in the client sites should be placed in the server site.<\/p>\n\n<p><strong>add_filter('sucw-roles-exclude-all-sync-except', []);<\/strong>\n<em>(SERVER)<\/em> Exclude all roles from synchronization except those specified\nIf active the 'sucw-block-user-roles' filter will be ignored\nparam array $array_exclude the list of default roles []\nsince 1.0.0<\/p>\n\n<p><strong>add_filter('sucw-block-user-roles', ['administrator']);<\/strong>\n<em>(SERVER)<\/em> If the user has one of the blocked roles I won't let them through\nvar array $block_user_roles\nreturn array\nsince 1.0.0<\/p>\n\n<h3>Below are the other filters and hooks you can use to customize your plugin configuration.<\/h3>\n\n<p><strong>apply_filters('sucw-update-roles', $roles)<\/strong>\n<em>(CLIENT)<\/em> The list of roles to save in the user profile when creating or updating the user. if it is an empty array it does not update the roles.\nsince 1.0.0<\/p>\n\n<p><strong>do_action( 'sucw-update-user', $user_id, $user_data )<\/strong>\n<em>(CLIENT)<\/em> It is called after updating or creating a user\nparam: int $user_id the user id\nobject $user_data user data\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters('sucw-remote-args', $args)<\/strong>\n<em>(CLIENT)<\/em> These are the arguments for the client to call the server\nparam array $args Default ['method':'POST', 'timeout':$timeout, 'redirection':2, 'httpversion':'1.0', 'blocking':true, 'headers':$headers, 'cookies':[]]\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters('sucw-remote-timeout', 15)<\/strong>\n<em>(CLIENT)<\/em> The server call times out\nparam int $timeout Default 15\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters('sucw-allow-metadata', true)<\/strong>\n<em>(CLIENT)<\/em> Allows you to update metadata\nparam bool $allow_metadata Allows you to update metadata\nif false it does not update the metadata, if it is an array it only updates the metadata present in the array\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters('sucw_register_url', $url)<\/strong>\n<em>(CLIENT)<\/em> Manages the registration link\nparam string $url il link di default\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters('sucw-lostpassword-url', url)<\/strong>\n<em>(CLIENT)<\/em> Manages lost password link\nparam string $url il link di default\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters( 'sucw-htaccess', true )<\/strong>\n<em>(CLIENT)<\/em> If the server uses htaccess or you need to make the call to the API via \/?rest_route (false)\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters('sucw-api-response', $response, 'login|check-user')<\/strong>\n<em>(SERVER)<\/em> The server's response to the login client api call\nparam array $response ['response_status'=&gt;'ok', 'user'=&gt;$user] | ['response_status'=&gt;'error', 'message'=&gt;'...']\nparam string $type login | check-user\nsince 1.0.0<\/p>\n\n<p><strong>apply_filters('sucw-log-limit', 1000)<\/strong>\n(SERVER &amp; CLIENT) The number of logs to keep on both server and client\nparam int $log_limit Default 1000\nsince 1.0.0<\/p>\n\n<h3>TIPS &amp; TRICKS<\/h3>\n\n<p>If the user misspells the password, it may appear as an error message that the user does not exist. To make the error messages more generic you can use the following code:<\/p>\n\n<pre><code>add_filter('login_errors', 'login_message', 10, 1);\nfunction login_message($error ) {\n    if ($error != '') {\n        $error = \"Incorrect username or password\";\n    }\n    return $error;\n}\n<\/code><\/pre>\n\n<p>To add a new role you need to create code like this on both the client and server sites<\/p>\n\n<pre><code>add_role('my_custom_role', \n    __( 'My Custom Role' ), \n    array( 'read' =&gt; true, 'read_private_posts' =&gt; true, )\n);\n<\/code><\/pre>\n\n<h3>Credits<\/h3>\n\n<p>Same user credentials as started in 2024 by Giulio Pandolfelli\nThanks to <a href=\"https:\/\/www.ekebu.com\">Ekebu<\/a> for the supports.<\/p>\n\n<!--section=installation-->\n<p>The plugin must be installed on two or more sites. The first site must be configured as a server, while the others as clients. Remember to save your settings once you have configured the plugin.<\/p>\n\n<p><strong>Server:<\/strong>\nClick on the \"Server\" box and save.<\/p>\n\n<p><strong>Client:<\/strong>\nCopy the token generated by the server and paste it into the client's \"Token\" box. Copy the server URL into the URL. Save.<\/p>\n\n<p>When you save the client settings it tries to connect to the server to verify that everything is working correctly. If the server does not have active htaccess, the API address changes and the following code must be applied to the client's functions.php:<\/p>\n\n<pre><code>add_filter( 'sucw-htaccess', 'sucw_htaccess' );\n function sucw_htaccess() {\n    return false;\n }\n<\/code><\/pre>","raw_excerpt":"It allows you to log in to two or more of your websites using the same credentials.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/193235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=193235"}],"author":[{"embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/giuliopanda"}],"wp:attachment":[{"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=193235"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=193235"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=193235"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=193235"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=193235"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/twd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=193235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}