将 wordpress 用户更改为管理员 [英] Changing a wordpress user to an admin
问题描述
我正在尝试建立生产 Wordpress 博客的本地副本.在生产中,我是用户但不是管理员,所以我试图在本地将自己更改为管理员.我按照this 使自己成为管理员的博客文章,因此我执行了以下 SQL 查询:
I am trying to set up a local copy of a production Wordpress blog. On production, I am a user but not an admin, so I am trying to change myself to an admin locally. I was following the directions on this blog post to make myself an admin, so I performed the following SQL queries:
INSERT INTO usermeta(user_id,meta_key,meta_value) VALUES(376, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO usermeta(user_id,meta_key,meta_value) VALUES(376, 'wp_user_level', 10);
然后我清除了浏览器 cookie 并再次登录,但是当我尝试导航到 http://localhost/wp-admin
时,我仍然收到您没有足够的权限来访问这个页."我什至删除了我的 APC 缓存文件并重新加载了 Nginx 和 PHP-FPM,这也没有改变任何东西.有人知道还有什么可以尝试的吗?
Then I cleared my browser cookies and logged in again, but when I tried to navigate to http://localhost/wp-admin
I still got "You do not have sufficient permissions to access this page." I even went so far as to delete my APC cache files and reload Nginx and PHP-FPM, which also didn't change anything. Does anyone know of anything else to try?
推荐答案
要设置 capabilities
和 user_level
你的 meta_key
值需要匹配您的数据库前缀.默认情况下,这是 wp_
(导致 wp_capabilities
和 wp_user_level
),但是在您的情况下会有所不同,因为您没有前缀.正确的 capabilities
值为 a:1:{s:13:"administrator";s:1:"1";}
.
To set the capabilities
and user_level
your meta_key
value needs to match your database prefix. By default this is wp_
(resulting in wp_capabilities
and wp_user_level
) however it would be different in your case as you don't have a prefix. The proper capabilities
value is a:1:{s:13:"administrator";s:1:"1";}
.
-- delete any existing values for this user
DELETE FROM usermeta WHERE user_id=376 AND (meta_key LIKE '%capabilities' OR meta_key LIKE '%user_level')
-- insert the capabilities and user_level for user_id 376
INSERT INTO usermeta(user_id,meta_key,meta_value) VALUES(376, 'capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO usermeta(user_id,meta_key,meta_value) VALUES(376, 'user_level', 10);
这篇关于将 wordpress 用户更改为管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!