WordPress JWT gives 403 after a user import: the row you missed
By Sophie Adams Published 10 min read
On this page (9 sections)
- The short version
- What the symptom tells you: password works, token fails
- Why it happens: three causes, most likely first
- The split test that separates token from import
- Why 401 and 403 point at different faults
- Repair the rows, then hand out new tokens
- How to stop the import dropping rows again
- What to run after the fix
- Questions people still ask
In short: JWT authentication fails after importing WordPress users because the import writes wp_users and skips the wp_usermeta role rows. Your password still works. The token validates, then the plugin finds no capability and returns 403. Repair wp_capabilities for each imported ID and the 403 clears.
Part of our guide on repair messed up custom fields
The password that opens wp-admin can still be rejected by the token endpoint, because the import carried the hash and skipped the row that says who the person is.
| Status code | 403 means no role |
|---|---|
| Status code | 401 means bad signature or expired |
| Status flag | user_status -1 is deleted |
| Hash type | phpass, portable |
| Rows dropped | wp_capabilities, wp_user_level |
| Fix order | status, capabilities, level, tokens |
The short version
- Log in at /wp-login.php first: success proves the phpass hash survived and the fault is metadata, not credentials.
- A 401 is a signature or expiry problem; a 403 means authenticated but no role.
- Users-only imports leave behind wp_capabilities and wp_user_level, and older importers set user_status to -1.
- wp-cli check-user-status returns ok, disabled, or not-existing, which tells you which row is missing.
- Repair the rows, then issue new tokens. Re-importing accounts duplicates user IDs and orphans posts.
- A JWT_AUTH_SECRET_KEY that differs between staging and production invalidates every token and looks identical to an import fault.
What the symptom tells you: password works, token fails
The account logs in at /wp-login.php with its imported password. The same account, given to the API, gets a 403. That split is the whole diagnosis, so start there before you touch keys or re-import anything.
A users-only import copies the wp_users table and skips the wp_usermeta rows that carry role and status. The password column arrives intact, which is why the admin login works. The capability rows never arrive, so WordPress authenticates the person and then finds nothing that says what they may do.
Nothing about the token is broken. Its signature verifies, its exp has not passed, and its user_id points at a real row. The denial happens after authentication, when the plugin asks whether the user has the capability the route requires.
That also points at where the fix lives. You repair rows in a database, not credentials in a table. And you do it once, on the site, rather than re-importing hundreds of accounts and creating duplicates. For the detail, see our notes on migrate blog posts between cms platforms without losing formatting.
If the login itself fails, stop and reset the password. A failing login means the fault is in the password column or a missing user row, and the split test below will not separate cleanly.
Why it happens: three causes, most likely first
Three faults produce this exact split. They land in a predictable order, and the import is the one most often missed.
A users-only import leaves the account looking like a person with no job. The role lives in wp_usermeta as a serialized array, and the import never carries it. Older importers also write user_status to -1, which marks the account as deleted and fails every capability check while still allowing a login in some setups. We cover fix tablepress csv duplicate rows in its own article.
Wp_user_level is a legacy column that most modern JWT plugins ignore, but some still read it. If your plugin checks it, an absent row reads as zero and denies access.
The token's user_id can also mismatch. An import remaps IDs, so a user who was 42 on the source site becomes 60 on the destination. A token minted for the old ID now points at the wrong person.
The plugin may authenticate against a second store, Firebase-style or SAML, that WordPress users never enter. Then no amount of row repair helps, because the imported accounts were never in the store the plugin queries. If that sounds like your situation, read up on move subtitles between video editors next.
- Missing capability rows: wp_capabilities never copied over, so the user has no role at all.
- Deleted status flag: user_status set to –1 by an older importer, blocking capability checks.
- Legacy level row: wp_user_level absent, which some plugins treat as no permission.
- User ID remap: the token names ID 42 but the import created ID 60.
- Second user store: the plugin checks Firebase Auth or SAML, not WordPress, so imported users never match.
The split test that separates token from import
Run the test in this order. It costs one login and one request, and it tells you which half of the system is broken.
The point of the test is that it does not fix anything. It only tells you where to look.
A failing login changes the answer entirely. Reset the password, then retry both paths. If the JWT endpoint now works, the fault was the password column, not the metadata.
Even a passing login does not close the hash question, because some importers copy the hash but change the password field. The command below rehashes a known password against the stored hash and answers that directly.
If the login works and the hash checks out, the fault is metadata. That is the case the rest of this page repairs.
- Log in at /wp-login.php with the imported password. Success means the phpass hash survived the import.
- If the login fails, reset the password and retest. A working reset with a still-failing JWT request points at metadata, not credentials.
- Request a fresh JWT for that same account and read the status code.
- Compare the two results: a working login plus a 403 means the fault is metadata, not credentials.
- Run wp user check-user-status <user> to read the status row, and wp user get <user> –field=caps to read the role.
Why 401 and 403 point at different faults
The status code does most of the diagnosing here, and the two codes mean opposite things about your import.
A 401 means the token itself was rejected. The signature did not verify, or the token is expired. That is a key problem or a clock problem, not an import problem.
A 403 means the token authenticated fine. The plugin knew who the person was, found the row, and then found no role or a deleted status. That is the missing usermeta rows showing up.
The most common cause of a 401 is a JWT_AUTH_SECRET_KEY that differs between environments. Staging holds one key, production holds another, and a token minted on one side fails on the other. Rotating the key invalidates every token issued before the change.
So: if the same token works on one site and fails on the other, the key differs. If both sites return 403, the import is at fault.
| Response | What failed | Where to look | What to do first |
|---|---|---|---|
| 401 | Signature or expiry | Secret key, server clock | Sync JWT_AUTH_SECRET_KEY across environments |
| 403 | Role or status | wp_usermeta rows | Repair wp_capabilities and user_status |
Repair the rows, then hand out new tokens
Work through the rows in this order. Each step ends with a check that tells you whether it worked.
Start with the status flag, because a deleted account fails every capability check and no amount of role repair will help while it is set.
Next check the capability row. An imported but empty array reads as a role with no permissions, which looks like a broken user but is really a broken row.
Some plugins still read the legacy level column, so set it where your plugin checks it. Modern WordPress does not use it, but the plugin may.
Users must fetch new tokens. A token minted before the repair can carry stale claims, and the fix is to re-authenticate, not to keep the old token.
Do not re-import accounts to fix this. A second import creates duplicate IDs and orphans the posts and comments that point at the originals.
- Check the status: wp user check-user-status <user>. It returns ok, disabled, or not-existing. Only ok continues.
- If it is disabled, run UPDATE wp_usermeta SET meta_value = '0' WHERE meta_key = 'user_status' AND user_id = <id>;.
- Read the role with wp user get <user> –field=caps. An empty or absent value means the row never arrived.
- Insert or repair the row: INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (<id>, 'wp_capabilities', 'a:1:{s:7:"subscriber";a:0:{}}');
- If your plugin reads the legacy column, set wp_user_level to 0 for subscribers, 1 for authors, 10 for admins.
- Have each affected user fetch a new token by logging in again. Old tokens carry pre-repair claims.
How to stop the import dropping rows again
The fix is a one-time repair. The habit is what prevents the next incident.
Import usermeta alongside users, never the users table alone. Whatever tool you use, confirm it carries the role and status rows, and check one account before you trust the batch.
Validate a handful of accounts before you go live. Pick three IDs, run the split test on each, and only then trust the rest.
Keep the JWT secret identical across environments, or mint tokens only on the environment that will use them. A key that differs between staging and production makes every token look broken.
Clone rather than import. A full site clone carries every row by construction, which is why it is the safer default for a move.
The free way is the manual SQL pass above on a staging copy, then a small script that repeats it for every affected ID. No plugin required, and no account re-created.
For the cloning step, managed WordPress hosts such as Hostinger offer a staging environment with daily backups, so you can test the import against a real copy instead of production. That does not repair the rows for you; it only gives you somewhere safe to run the repair and confirm it before touching live users.
- Clone carries every row by default
- Daily backups to roll back
- Test the repair safely
- Does not repair rows automatically
- Staging still needs a synced JWT key
- Costs money if not already subscribed
What to run after the fix
The repair is not done when one account works. Confirm the batch, then move the users forward.
Re-run the check on every affected ID, not just the one you tested. A loop over the list catches the accounts where the import skipped differently.
Confirm the capability row now holds a real role, not an empty array. An empty array passes a quick check and still denies access.
Then tell users to log in again and fetch fresh tokens. That step is the one that gets skipped, and it is why the 403 returns a week later.
If a 401 shows up after you fixed the 403, the key changed or the server clock drifted. Check the secret and the time source before you doubt the repair.
Watch one account for a few days. A clean token and a clean admin login, side by side, is the sign the import is whole.
Repair the rows and issue new tokens. Re-importing accounts is the path that turns a missing row into orphaned content.
Questions people still ask
Will re-importing the accounts fix the 403?
No, and it makes things worse. A second import creates duplicate user IDs, so posts and comments that point at the original row end up orphaned. Repair the missing usermeta rows instead, then have users fetch new tokens.
Why did my tokens all stop working after I rotated the secret key?
Every token is signed with JWT_AUTH_SECRET_KEY, so changing it invalidates everything issued before the change. Users must authenticate again to get tokens signed with the new key. This looks identical to an import fault, which is why the split test matters.
Does wp_user_level still matter in modern WordPress?
WordPress itself does not use it, but some JWT plugins still read it for a permission check. If yours does, an absent row reads as zero and denies access. Set it to match the role, or confirm your plugin ignores it before you skip the row.
Can the import remap user IDs and break tokens?
Yes. An import can assign a new ID to an existing account, so a token that names the old ID points at the wrong person or at nothing. Compare the ID in the token against the ID in the database before you assume the rows are the problem.
Is the token itself broken?
Usually not. A 403 means the token verified and authenticated fine, then failed the capability check. A 401 would mean the token is the problem, from a signature mismatch or expiry. The code tells you which.
Do I need a plugin to repair the rows?
No. A single UPDATE for the status flag and an INSERT for the capability row fix it, and wp-cli reads the values back for you. Run it on staging first, then repeat across the affected IDs.