0

I wrote a series of bash scripts that use git to push my files, wp-cli to export/import my dbs, and rsync to upload/download dbs, and wp-cli to search-replace usernames & urls between test, staging, and prod.

The scripts work as expected on 27 out of 28 websites.. push/pull no problems However for one website, following a completely successful error free push. the admin user looses the admin role.

My question is not about the scripts. The scripts work.

Question:
What are the wordpress that settings that I can check/verify/adjust prior to migration that may prevent the administrator role from being stripped from my Admin User upon migration?

Another odd behavior
Admin role stripping.... is not specific to a single admin user. If I migrate from test to staging, all admin users currently on staging, will be stripped of their admin role.

Example:
Before Migration Staging Server has this admin user in wp_capabilities: enter image description here

While Test server has this admin user in wp_capabilities: enter image description here

Following migration from test to staging...Admin user loses admin privileges and STAGING wp_capabilities now has the test server's user id (11 instead of 2): enter image description here Meanwhile wp user list still shows the user id as 2.

Confusion
As I am excluding the users / users_meta tables from my db import/exports workflow, I don't understand how this behavior is possible. The admin user info is not moved between servers.

My export command:

Additional Notes
1.) In my workflow, I exclude the user / usermeta when I export the db? Could my staging server be missing important info from these tables and therefore be the stripping admin privileges?

2.) This site was previously a subsite of a multisite, so I was careful to replace the nickname for the current admin. And wp_capabilities verifies that the sole user (admin) has an admin role: a:9:{s:13:"administrator";a:2:

3.) When I activate the debug.log on staging all I get are php warnings, deprecation messages, and notices. No errors.

4
  • Did you try creating a new admin user and see if it has the same problem? It's hard to troubleshoot the actual issue without knowing all your scripts. Your serialized data string is incomplete here in your question as well.
    – rudtek
    Commented Oct 4, 2022 at 16:21
  • If I create a new admin user, I can access the backend. Then I push again (excluding user tables)... and the -new- admin user also becomes locked out
    – mjones
    Commented Oct 4, 2022 at 16:39
  • I will post the scripts in the morning.. need a few hours shut eye.
    – mjones
    Commented Oct 4, 2022 at 16:44
  • 2.5 hours after bedtime.. I figure it out... for whatever strange reason the admin user is loosing his role post migration. If I use wp-cli to restore the role from command, all is well. I inspect the db and there are no errors. I will edit this questions in a few hours. I would love to know how/why this admin is loosing his role
    – mjones
    Commented Oct 4, 2022 at 18:23

1 Answer 1

0

I went ahead posted a better question describing my problem, but as I wrote it I actually found the cause of the problem and solution.

cause of problem:
only the wp_users table was being excluded from my db exports on Test. so the Test server's wp_usermeta table was being sent to Staging and created the odd behaviors found above.

Solution:
correctly exclude both wp_users and wp_usermeta tables

problem solved.

Notice how the user id changed after a migration in the above screenshots? wp_usermeta was the cause

I honestly don't how this version of my script lost the wp_usermeta exclusion.. all others have it.... strange.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.