简体   繁体   中英

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.

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

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.

I added the function myplugin_activate() line and since then it doesnt break 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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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