简体   繁体   English

用于创建新用户的插件(激活插件后)

[英]Plugin to create new user (Upon plugin activation)

I am trying to use the function reference wp_insert_user (as documented here http://codex.wordpress.org/Function_Reference/wp_insert_user#Usage ) to create a new user account when the plugin is run. 我正在尝试使用功能参考wp_insert_user(如http://codex.wordpress.org/Function_Reference/wp_insert_user#Usage所示 )在运行插件时创建新的用户帐户。

How do I specify what privledges the account has as well as the login name / pass? 如何指定帐户拥有的特权以及登录名/密码?

My plugin code currently looks like this: 我的插件代码当前如下所示:

http://oi51.tinypic.com/i74i8w.jpg http://oi51.tinypic.com/i74i8w.jpg

UPDATE 更新

I tried to test the plugin as is , and at the moment it doesn't create the account. 我尝试按原样测试该插件,目前还没有创建该帐户。

At first, it broke WordPress and would cause none of the pages (even admin panel) not to load. 起初,它破坏了WordPress,将导致所有页面(甚至管理面板)均无法加载。

I added the function myplugin_activate() line and since then it doesnt break WordPress. 我添加了功能myplugin_activate()行,从那时起它就不会破坏WordPress。

Anyone have any insight on getting the account created upon activation? 任何人都对激活时创建帐户有任何见识?

Well, the link you have posted contains information about how to specify login, password and so on :) just look at the notes section, all possible options are listed. 好了,您发布的链接包含有关如何指定登录名,密码等信息:)只需查看注释部分,列出所有可能的选项。

User is not created because your function is not called, simple as that. 由于未调用您的函数而未创建用户,就这么简单。 You need to register a hook. 您需要注册一个钩子。 Add this line before ?> : 在?>之前添加此行:

register_activation_hook( __FILE__ ,'myplugin_activate');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM