Awesome plugin that works really well, but the best thing about it is Tim’s support. He’ll answer you immediately and help you until it works. Thanks Tim, you’re great!

While getting frustrated with all the generic OAuth2 plugins and what seems an impossible task to get Nextcloud to work with them, I have built my own simple “WordPress Nextcloud SSO OAuth2” plugin that’s built so you can login to WordPress with a Nextcloud user, it will just work without much hassle, you just need to go to Settings -> Security in your Nextcloud install and get a Client Identifier and Secret key to enter into the plugin.
Options wise I have tried to keep it simple, you can set the redirect URL on successful login, auto add a login button to the login form, change the login button text, create an account if no user exists, what default WordPress role to match new users to, and an advanced multi-group/role mapping option with the ability to disable registrations depending on what Nextcloud group the user is and finally how to match users coming over from Nextcloud, by email or username.
There is also a shortcode to add a login button anywhere
[nextcloud_login class="btn"]button text[/nextcloud_login]
A URL that you can use to automatically redirect the user to your Nextcloud install so they can login which will be
www.example.com/wp-login.php?nc-sso=redirect
You will also be able to define your Nextcloud secret key in the wp-config.php file so it’s not stored in the database
define('NEXTCLOUD_SECRET', 'Your Secret key');
A simple OAuth2 plugin so you can log in to your WordPress site with your Nextcloud account. Add a Nextcloud login button to the WordPress login page, or anywhere with the login block or a shortcode, match Nextcloud groups to WordPress roles (and keep them in sync on every login), and choose where users go after logging in.
Optional extras include Nextcloud profile pictures, keeping names and email addresses in sync, Nextcloud-only login, an hourly check that Nextcloud is online, and WP-CLI commands.
If you use the External sites app in Nextcloud, set the URL to www.example.com/wp-login.php?nc-sso=redirect and users are logged in without clicking a button.
The plugin has been tested with Nextcloud 20.0.14 to 35.0.3.
If you have any problems please reach out on the support forum or directly here.
Note this is not an official plugin from Nextcloud, it is just from someone that uses it with WordPress a lot.
The settings page (Settings -> Nextcloud OAuth2) walks you through it:
A setup checklist at the top of the settings page shows what is left to do, and Test connection ticks off the steps it has checked. Once “Save and test with secret” works, steps 1 and 2 fold into one line saying which Nextcloud you are connected to, and the longer explanations move behind “More info” links. Click the line to open the steps again.
The address of your Nextcloud, e.g. https://cloud.example.com/. Include any subfolder (https://example.com/cloud/), and include /index.php/ if your Nextcloud URLs have it (https://example.com/index.php/).
Settings -> Nextcloud OAuth2, or click “Settings” under the plugin on the Plugins page.
In the block editor, add the “Nextcloud Login Button” block. You can change the text, alignment, colours, font size, padding and border, make it full width, and choose to bring people back to the same page after they log in. It is hidden from users who are already logged in, or you can show them a message instead.
There is also a shortcode, [nextcloud_login class=”btn”]button text[/nextcloud_login]. It also takes a style attribute, and is hidden from users who are already logged in. For just the URL, e.g. in a menu, use [nextcloud_login_link] or www.example.com/wp-login.php?nc-sso=redirect.
The button on the WordPress login page has the CSS class tims-nso-login-button if you want to restyle it.
Each WordPress account is linked to a Nextcloud user ID, which Nextcloud users cannot change. Accounts the plugin creates are linked automatically. Existing users link their account from their profile (Users -> Profile -> Link my Nextcloud account), or an administrator enters their Nextcloud user ID on the user edit screen. The Users list can show who is linked (Advanced options).
Step 3 asks “How should their existing WordPress account be found?” for someone logging in with Nextcloud for the first time:
After that, every login uses the Nextcloud user ID. Only match by email address or username if you control every Nextcloud account. Existing administrators, editors, shop managers and other privileged accounts are never linked automatically, they link from their profile instead. New accounts are still created with the role from your settings, including administrator.
The next question, “If they do not have a WordPress account yet”, either creates a new account for them or does not let them log in. A summary under both questions shows what will happen on a first login.
Yes, all your settings are kept, and your old matching setting is carried over:
Subscribers, customers and other users without editing or admin access log in as before, and are linked to their Nextcloud user ID on their next login. Creating accounts for new users carries on working too.
The one change is that accounts with editing or admin access are no longer matched by email address or username, as that is what allowed someone to take over an administrator account. They need linking once, either:
A notice in the WordPress admin lists the accounts that still need linking. Accounts the plugin created have a random password, so use “Lost your password” to get in, or have an administrator enter their Nextcloud user ID. Once everyone is linked, click “Only match by Nextcloud user ID” in the notice.
Yes, in Step 3:
Each Nextcloud login then sets the user’s roles from their Nextcloud groups, so removing someone from a group in Nextcloud removes the role at their next login. Set it to No and groups are only used when an account is created, as before 2.3.0.
“Save and test with secret” in step 2 loads your Nextcloud groups, and “Refresh groups from Nextcloud” loads them again later. Click a group to add it to the role you last clicked, groups already matched to a role are shown in blue. Sign in as a Nextcloud administrator to load every group. Groups are matched by their Nextcloud group ID, which is usually the same as the name.
If someone is in groups for more than one role, you can give them every matching role or only the highest one. Drag the roles to change their order.
The “Who gets which role” box under the groups lists who gets which role as you make changes, which groups are not used yet, and what everyone else gets.
This is off by default, so updating does not change anyone’s roles until you turn it on.
The settings page has two test buttons:
Optional extras at the bottom of the settings page, all off by default:
Deactivating the plugin keeps everything. Deleting it also keeps everything, unless you tick “Delete all plugin data when the plugin is deleted” in the Advanced options, then the settings, account links, copied profile pictures and debug log are removed. A log file set with TIMS_NSO_LOG_FILE is never deleted.
To start again without removing the plugin, use “Delete all plugin data now” in the Advanced options. It deletes the same data straight away, after asking you to confirm. WordPress users are kept, but linked accounts need linking again. A Secret in wp-config.php is not removed.
Sometimes a new version is available to test before it is released. If there is one, you can download it from the Advanced tab on this plugin’s page (Development Version, under Previous Versions). Please test it on a staging site first, and let me know how it goes on the support forum. Your site will update to the full release automatically when it comes out.
Yes, there is:
tims_nso_authorize_url which is the Nextcloud URL the user gets redirected to, and is also the last hook before they go off to your install of Nextcloud, example:
add_filter('tims_nso_authorize_url', 'custom_function_name_one');
function custom_function_name_one($authorize_url){
// custom code
return $authorize_url;
}
tims_nso_successful_login_redirect which is the URL the user goes to after successfully coming back from Nextcloud, example:
add_filter('tims_nso_successful_login_redirect', 'custom_function_name_two');
function custom_function_name_two($redirect_url){
// custom code
return $redirect_url;
}
tims_nso_nextcloud_login_button_url which is the URL the login button and shortcode login button uses, example:
add_filter('tims_nso_nextcloud_login_button_url', 'custom_function_name_three');
function custom_function_name_three($url){
// custom code
return $url;
}
tims_nso_nextcloud_user_matched which is the WordPress WP_User (Object) and the user data (Object) from Nextcloud for the successful matched user. It runs after the user has been logged in, so it is useful for reading the Nextcloud data (e.g. to update a profile field), returning a different user does not change who is logged in, example:
add_filter('tims_nso_nextcloud_user_matched', 'custom_function_name_four', 10, 2);
function custom_function_name_four($user,$nextcloud){
// custom code
return $user;
}
tims_nso_is_privileged_user decides which accounts are never linked automatically by email address or username. By default this is any account that can do more than a subscriber or WooCommerce customer (edit posts, upload files, manage users, manage WooCommerce etc.). The example below also protects a custom capability:
add_filter('tims_nso_is_privileged_user', 'custom_function_name_five', 10, 2);
function custom_function_name_five($is_privileged, $user){
if(user_can($user, 'my_custom_capability')){
return true;
}
return $is_privileged;
}
Only make this return false if you control every Nextcloud account and users cannot change their own email address, otherwise someone could take over an administrator account.
tims_nso_instance which is the name of the Nextcloud server saved with each linked account (by default the host and path of your Nextcloud URL, e.g. cloud.example.org). Links made with a different server are ignored, so if you move Nextcloud to a new address you can use this to keep the existing links working, example:
add_filter('tims_nso_instance', 'custom_function_name_six');
function custom_function_name_six($instance){
// Nextcloud moved from cloud.old-example.org, keep using the old links
return 'cloud.old-example.org';
}
tims_nso_roles_from_groups which is the list of WordPress roles worked out from the user’s Nextcloud groups, used when an account is created and when roles are updated on login, example:
add_filter('tims_nso_roles_from_groups', 'custom_function_name_nine', 10, 2);
function custom_function_name_nine($roles, $nextcloud){
// custom code
return $roles;
}
tims_nso_sync_can_remove_role decides if “Update WordPress roles from Nextcloud groups on every login” can remove a role from a user. By default every role can be removed except Administrator. The example below also protects the Editor role, return true for administrator if you want Nextcloud to be able to remove it, the last administrator on the site is still never removed:
add_filter('tims_nso_sync_can_remove_role', 'custom_function_name_eleven', 10, 3);
function custom_function_name_eleven($can_remove, $role, $user){
if($role == 'editor'){
return false;
}
return $can_remove;
}
tims_nso_allow_login decides if a Nextcloud user can log in, return false to stop them. It runs before an account is linked or created, with the user data (Object) from Nextcloud and the linked WordPress user (WP_User, or false if they are not linked yet). The example below only lets members of the Nextcloud “staff” group log in:
add_filter('tims_nso_allow_login', 'custom_function_name_twelve', 10, 3);
function custom_function_name_twelve($allowed, $nextcloud, $user){
if(empty($nextcloud->groups) || !in_array('staff', $nextcloud->groups, true)){
return false;
}
return $allowed;
}
tims_nso_new_user_data which is the user data used to create a new account (user_login and user_email by default), and the user data (Object) from Nextcloud. You can add anything wp_insert_user() accepts, the example below uses the Nextcloud display name:
add_filter('tims_nso_new_user_data', 'custom_function_name_thirteen', 10, 2);
function custom_function_name_thirteen($userdata, $nextcloud){
if(!empty($nextcloud->displayname)){
$userdata['display_name'] = $nextcloud->displayname;
}
return $userdata;
}
An account is not created if the username or email address is already used on the site, the user is asked to link their existing account instead.
tims_nso_logout_url which is the address linked users are sent to when “Send users to Nextcloud after logging out” is on, your Nextcloud URL by default, example:
add_filter('tims_nso_logout_url', 'custom_function_name_seventeen');
function custom_function_name_seventeen($logout_url){
return 'https://cloud.example.org/apps/files/';
}
tims_nso_register_url which is the address the register link goes to, example:
add_filter('tims_nso_register_url', 'custom_function_name_twenty');
function custom_function_name_twenty($url){
return 'https://www.example.org/join/';
}
tims_nso_monitor_email which is who the Nextcloud online check emails, the addresses in “Send alerts to” or the site administrator email by default, example:
add_filter('tims_nso_monitor_email', 'custom_function_name_eighteen');
function custom_function_name_eighteen($email){
return 'it@example.org';
}
tims_nso_check_available decides if the plugin checks Nextcloud is up before sending someone there to log in. If Nextcloud cannot be reached or is in maintenance mode, people see a message instead of a browser error. Return false to skip the check, for example if your Nextcloud blocks status.php:
add_filter('tims_nso_check_available', '__return_false');
Yes, tims_nso_user_linked runs when a WordPress account is linked to a Nextcloud account (from the profile page, by an administrator, when an account is created, or when it is linked automatically), and tims_nso_user_unlinked runs when the link is removed, example:
add_action('tims_nso_user_linked', 'custom_function_name_seven', 10, 2);
function custom_function_name_seven($user_id, $nextcloud_user_id){
// custom code
}
add_action('tims_nso_user_unlinked', 'custom_function_name_eight');
function custom_function_name_eight($user_id){
// custom code
}
tims_nso_roles_synced runs when a user’s roles are changed by “Update WordPress roles from Nextcloud groups on every login”, with the roles that were added and removed, example:
add_action('tims_nso_roles_synced', 'custom_function_name_ten', 10, 3);
function custom_function_name_ten($user_id, $added_roles, $removed_roles){
// custom code
}
tims_nso_user_created runs after the plugin creates a new account, with the new user ID and the user data (Object) from Nextcloud, example:
add_action('tims_nso_user_created', 'custom_function_name_fourteen', 10, 2);
function custom_function_name_fourteen($user_id, $nextcloud){
// custom code, e.g. send a welcome email
}
tims_nso_logged_in runs after someone has logged in with Nextcloud, with the WordPress WP_User (Object) and the user data (Object) from Nextcloud, example:
add_action('tims_nso_logged_in', 'custom_function_name_fifteen', 10, 2);
function custom_function_name_fifteen($user, $nextcloud){
// custom code
}
tims_nso_login_error runs when a Nextcloud login, account link, group load or connection test fails, with the error code (e.g. not-linked, no-role, returned-invalid) and what was being done (login, link, groups or test), example:
add_action('tims_nso_login_error', 'custom_function_name_sixteen', 10, 2);
function custom_function_name_sixteen($error, $intent){
// custom code, e.g. log failed logins
}
tims_nso_monitor_checked runs after each Nextcloud online check, with the status (ok, maintenance or down), the previous status and any error, for example to send an alert somewhere else:
add_action('tims_nso_monitor_checked', 'custom_function_name_nineteen', 10, 3);
function custom_function_name_nineteen($status, $previous_status, $error){
// custom code
}
The standard WordPress wp_login action also runs after a successful Nextcloud login.
Yes, there are:
NEXTCLOUD_SECRET to store your Nextcloud secret key in wp-config.php instead of the database:
define('NEXTCLOUD_SECRET', 'Your Secret key');
TIMS_NSO_LOG_FILE to choose where the debug log is saved, ideally somewhere outside your web root. By default it is saved in wp-content/uploads/tims-nso-logs/ with a random file name:
define('TIMS_NSO_LOG_FILE', '/home/example/logs/nextcloud-sso.log');
Yes:
wp tims-nso status
wp tims-nso list
wp tims-nso list --linked --format=csv
wp tims-nso link <user> <nextcloud-id>
wp tims-nso unlink <user>
status shows the main settings and how many users are linked. list shows every user with their Nextcloud user ID, server and last Nextcloud login (–format can be table, csv, json or yaml). link and unlink take a WordPress user ID, username or email address. Run wp help tims-nso for the details.
Yes, with the WP-CLI link command above, for example:
wp tims-nso link 12 jsmith
wp tims-nso link jo@example.org jsmith
Use the Nextcloud user ID (login name), not the display name. The link is saved in two user meta fields, tims_nso_nc_uid (the Nextcloud user ID) and tims_nso_nc_instance (the Nextcloud server, see the tims_nso_instance filter above), if you would rather set them another way. The Nextcloud column on the Users list (Advanced options) shows who is linked, and shows “(other server)” if the instance does not match.
Before you go off to Nextcloud the site needs to store a unique key to verify the response when you come back, if this key is removed before you come back this is when you see this message.
By default, the key is stored in the PHP session but if you are having trouble you can open Advanced options in the plugin settings and set the “Storage Type” to Cookie and this should solve the issue.
If you check the JS console log and see a message like “Refused to send form data to … because it violates the following Content Security Policy directive….” then you need to edit your Nextcloud config file, usually located at nextcloud/config/config.php and add the line: ‘overwriteprotocol’ => ‘https’,
Yes, it comes with German, French, Dutch, Spanish and English (Pirate) translations. If you would like to help translate it into your language, or improve a translation, you can on translate.wordpress.org.
Nope, just a simple free plugin to enable you to log in to your site with Nextcloud.
Please report security bugs found in the source code of the Tim’s Nextcloud SSO OAuth2 plugin through the Patchstack Vulnerability Disclosure Program. The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
If you have any problems please reach out on the support forum or directly here. I will try my best to help.
Awesome plugin that works really well, but the best thing about it is Tim’s support. He’ll answer you immediately and help you until it works. Thanks Tim, you’re great!
I have been trying to find a plugin to work with nextcloud for over a year and gave up, heard about this on the nextcloud forum and it just worked. Keep up the good work!
You have saved me from copying account details over and over, again and again.
Finally a simple to install and use SSO plugin!
Few options, but all the ones you might need.
And Tim really cares about helping users, even those like me who use weird versions of NextCloud.
I have been trying to get my WordPress site linked to my NextCloud file server for well over a year. I needed to have a small main site (WordPress) while storing all of my 1000+ PDF document files on a large Cloud File Server (NextCloud). I also needed to maintain user access to our Cloud Server (for alternate access).
I tried many plugins, Third Party solutions (KeyCloak, Auth0, MiniOrange, Okla, etc). I managed to get Auth0 running but it had a problem with authenticating with a commonly used version of a common web browser (not their fault – the browser had faulty code in their implementation of the handshaking procedure).
Left it all alone for several month’s until our old web site died – which is why I was trying to get a new one working with our existing Cloud Server.
Then this plugin showed up and it was so simple to setup and run.
I had an issue with the default wp-login returning an error. So I setup fresh servers and still no joy. In desperation I contacted the Developer.
He solved the problem within a day! Great service and I am very grateful to him for both publishing this great plugin and for the incredible response to my problems.
Highly Recommended!
I don’t have much to say. It was super simple to setup and works perfectly. Thanks for providing this plugin for free!
Simple to configure and esay to set up. Great work!
Works like a charm
Intuitive design, works the first time you try it. Tim, can I spend you a coffee or something as a thank you?
Release Date: 30th November 2026
2.2.0 was only used for testing and was not released, its changes are included here.
Updating from before 2.1.0: your settings are kept, but administrators, editors and other privileged users need to link their Nextcloud account once from their profile, using their WordPress password. A notice in the WordPress admin lists who still needs linking. Already on 2.1.0? Linked accounts carry on working.
Roles from Nextcloud groups
Logging in
A simpler settings page
Advanced options, all off by default
For developers
wp tims-nso status, list, link and unlink.Security and other changes
Release Date: 26th November 2026
Security fix, please update.
Release Date: 22nd May 2025
Release Date: 10th August 2023
Release Date: 1st July 2022
Release Date: 27th June 2022
Release Date: 23rd May 2022
Release Date: 19th May 2022
Release Date: 6th May 2022
Release Date: 18th March 2022
Release Date: 17th March 2022
Release Date: 17th March 2022
Release Date: 25th February 2022
Release Date: 25th February 2022
Release Date: 25th February 2022
Release Date: 11th February 2022