Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Use members from 1 site on another one

Users created in Site_A have roles assigned to them. Same users are available in Site_B but they have no roles assigned. Create a PHP script sync-admins.php with the following code in it:

<?php
// load WordPress environment
require( 'wp-load.php' );

// REPLACE 'siteb_' with table prefix of Site_B in line below!
$tblPrefixOfSite_B = 'siteb_';

// administrator's capability
$capability = array( 'administrator' => TRUE );

if ( current_user_can( 'administrator' ) ) {
    update_user_meta( get_current_user_id(), $tblPrefixOfSite_B . 'capabilities', $capability );
    update_user_meta( get_current_user_id(), $tblPrefixOfSite_B . 'user_level', 10 );
    echo 'Success!';
} else {
    echo 'You must be logged in as an administrator';
}
?>

Place this script in root of Site_A. Login as an administrator to Site_A. Now execute the script. This will properly assign a role of ‘administrator’ to the administrator of Site_B. Now you can login to Site_B as an administrator and add roles to other users.

Related Posts:

  1. Whats the best way to share user data across multiple WordPress websites?
  2. Replacing the WordPress password validation
  3. WordPress auto login after registration not working
  4. Allow up to 5 Concurrent Login Sessions
  5. Why does is_user_logged_in() return false after redirect from another site?
  6. Pre-populate Username Field
  7. How to get user ID during registration and add it to a custom table
  8. How to keep track of user logins?
  9. Get user info outside WordPress
  10. How can I secure a WordPress blog using OpenID from a single provider?
  11. Is it possible to get a user with just the password field?
  12. Redirect after login based on user role (custom login page)
  13. Check for user meta data at Login
  14. Redirect User to Homepage if no other redirect is specified
  15. My custom page template with is_user_logged_in() does not detect that I’m logged in
  16. Use phpbb user database for WordPress
  17. WordPress to use Drupal users’ credentials
  18. Share user table from WP with Drupal
  19. How can I allow password reset based on logins containing the @ character?
  20. A way to count logged in users and display count?
  21. stop login if user_status equal zero
  22. How do i make my wordpress website private?
  23. Redirect user to login before viewing custom post
  24. Change the user_login at registration
  25. Max no of simultaneous active sessions for a single user
  26. When I try to login in wordpress it is showing “USER Doesn’t Exists”
  27. Should I encrypt the response that triggers an Ajax action? Is nonce sufficient?
  28. Redirect subscribers to last viewed page after log-in
  29. User Meta Data in a Sortable Table
  30. wordpress disable login for unverified user
  31. Reset Password policy
  32. Rewrite Rules and Login Issue
  33. Is possible to allow user to login with different role?
  34. Use WordPress Login for a non-wordpress site
  35. WordPress Login Customization for External Authentication
  36. Does wordpress support natively the concept of logging-in users? (not admins, but users of the website)
  37. Is there any action /filter hook I can use to disable login for some user role?
  38. How to check User Role and redirect to specific page according to Role when login in WordPress?
  39. Display video on homepage for users who have not logged in
  40. How do you manage your pages or functions that require logged-in users?
  41. Querying specific table row by current user login
  42. How can i login with user’s password in WordPress being an admin?
  43. Delete a user from frontend
  44. Check if user is logged in via JS? [duplicate]
  45. Can I edit the database to change a login?
  46. how redirect users to custom login page when “login to reply” is clicked? [duplicate]
  47. User(s) already exists show error please provide a valid username
  48. wp_generate_password sets password but can’t login using created password
  49. add class to element if user is not logged in [closed]
  50. Is there a way to call via javascript if a user is logged-in on a static html file?
  51. Restricting wordpress login sessions for a web app
  52. How to connect wordpress user with my own APP user?
  53. How to change default username field after login
  54. The same session information for peer users on two different WordPress servers
  55. WP users cant reset password
  56. Check for empty username or password on login
  57. $user_login is not working if author has only 1 post
  58. Specific Content on pages based on user
  59. user and usermeta table not found
  60. custom login form, guide me
  61. Changing user_login ends current session
  62. Current User Seeing Another Logged In User Info
  63. Redirect based on log-in status per JavaScript
  64. Securely log in a user without a password using a link?
  65. Integrating Facebook Registration (and Login) on a WordPress page
  66. WordPress – Security Question at Login from User’s Meta Data
  67. determine active user browser at the same time
  68. How to track all users logged into a site?
  69. Cant edit profile from frontend
  70. How to authenticate/verify login credentials & check for user meta without logging in?
  71. Will users still be able to log in if I change host?
  72. redirect to my login page if not logged in
  73. If the current user is an administrator or editor
  74. Editor can create any new user except administrator
  75. How do I add a field on the Users profile? For example, country, age etc
  76. How do I display logged-in username IF logged-in?
  77. How to allow an user role to create a new user under a role which lower than his level only?
  78. user_login vs. user_nicename
  79. How to programatically change username (user_login)?
  80. Change the Author Slug from Username to Nickname
  81. Remove Ability for Other Users to View Administrator in User List?
  82. Difference between update_user_meta and update_user_option
  83. Make display name unique
  84. Make WooCommerce pages accessible for logged in users only
  85. Find out if logged in user is not subscriber
  86. WordPress usermeta scaling for thousands of users
  87. How to get WordPress Username in Array format
  88. Display user registration date
  89. Is there a is_user_logged_in() for multisite?
  90. Get multiple roles with get_users
  91. get_user_meta() doesn’t include user email?
  92. Confirmation required on email change
  93. How to Merge Two Authors Into One?
  94. get_current_user_id() returns 0?
  95. How to get userid at wp_logout action hook?
  96. Groups of capabilities: users with multiple roles?
  97. Is there a way to merge two users?
  98. User-edit role setting distinct from wp_capabilities? [closed]
  99. List users by last name in WP_User_Query
  100. What’s the difference between the capability remove_users and delete_users?
Categories users Tags login, table, users
License of the used Bootstrap Theme is not GPL compatible
Use BuddyPress data in loop (mkdir)

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress