Seamlessly authenticate WordPress users across your main site and subdomain with separate databases. Simple, secure, and production-ready.
WP Subdomain Login allows you to create a login form on your main WordPress site that authenticates users and redirects them to a subdomain site, even when both sites use completely separate databases.
Works with independent databases on different servers
HMAC-SHA256 encrypted tokens with 5-minute expiry
Simple shortcode or PHP function implementation
wp-config.php on both siteswp-subdomain-login-v1.0.1.zipwp-subdomain-login folder to /wp-content/plugins/Generate a random secret key for secure token encryption:
php -r "echo bin2hex(random_bytes(32));"
A quick alternative way to generate a secret key is to use a Secret Key Generator. Click the link and copy the key.
Add this line to wp-config.php on BOTH sites (before "That's all, stop editing!"):
define('SUBDOMAIN_AUTH_SECRET', 'your-generated-secret-key-here');
Add this shortcode to any page or post on your main site:
[wp_subdomain_login subdomain="https://subdomain.example.com" redirect="/dashboard"]
| Parameter | Required | Description | Example |
|---|---|---|---|
subdomain |
Required | Full URL of the subdomain site | https://app.example.com |
redirect |
Optional | Path to redirect after login (default: /) | /dashboard |
// Redirect to homepage
[wp_subdomain_login subdomain="https://app.example.com"]
// Redirect to specific page
[wp_subdomain_login subdomain="https://app.example.com" redirect="/welcome"]
// Redirect to user profile
[wp_subdomain_login subdomain="https://members.example.com" redirect="/profile"]
For theme developers, you can use the PHP function directly in your templates:
wp_subdomain_login_display_form( $subdomain_url, $redirect_path = '/' );
| Parameter | Type | Required | Description |
|---|---|---|---|
$subdomain_url |
string | Required | Full URL of the subdomain |
$redirect_path |
string | Optional | Path to redirect after login (default: /) |
<?php
// In your theme template
if ( function_exists( 'wp_subdomain_login_display_form' ) ) {
wp_subdomain_login_display_form(
'https://app.example.com',
'/dashboard'
);
}
?>
date command on both serversDownload the plugin and start authenticating users across your WordPress sites today.
Download Plugin v1.0.1