User role changing on login
-
Hi all!
I am an administrator for a couple of wordpress sites. I am trying to add a new user with the editor role (we only have the standard roles). I have created the new user and assigned them the editor role on creation. However, when they login they only have ‘subscriber’ access. On checking the database I can see that their setting in wp_usermeta ‘wp_5_capabilities’ changes when they login.
I’ve had a good search for related issues and the 2 recommendations seem to be:
1) Disable any plugins and re-enable them one by one until you find which is causing the issue. I disabled all the plugins and the problem was still there.
2) Amend the settings in wp_usermeta to give the user the ‘editor’ role. Indeed some internal documentation suggests:Get the users’ ID
SELECT * FROM wp_usermeta WHERE user_id = (SELECT ID FROM wp_users WHERE user_login 'username' )Extract their user_id and update the wp_usermeta table
Icon
This instance is to grant editor access to the staff and student news blogs – first you must identify the blog ID and substitute the appropriate number in wp_x_capabilities….INSERT INTO wp_usermeta 'user_id', 'meta_key', 'meta_value' values '^_USER_ID_FROM_UP_THERE_^', 'uon_author', '^_USERNAME_FROM_UP_THERE_^' UPDATE wp_usermeta SET meta_value = 'a:1:{s:6:"editor";s:1:"1";}' WHERE meta_key = 'wp_capabilities' AND user_id = '^_USER_ID_FROM_UP_THERE_^' UPDATE wp_usermeta SET meta_value = 'a:1:{s:6:"editor";s:1:"1";}' WHERE meta_key = 'wp_5_capabilities' AND user_id = '^_USER_ID_FROM_UP_THERE_^' UPDATE wp_usermeta SET meta_value = 'a:1:{s:6:"editor";s:1:"1";}' WHERE meta_key = 'wp_4_capabilities' AND user_id = '^_USER_ID_FROM_UP_THERE_^‘
Unfortunately the role still reverts back to subscriber when the new user logs in. Interestingly I was able to get them to have the ‘editor’ privileges but I think this was when they were already logged in, I then updated the database and they refreshed their page. This again reverted back to ‘subscriber’ when they logged out and back in again.
Does anyone have any suggestions as to how to resolve this?
The topic ‘User role changing on login’ is closed to new replies.