0

Forgive me if I'm in the wrong place, I'm digging the Stack Exchange world.

This functional sql code creates a user in wordpress:

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `display_name`)
VALUES ('USER', 'PASS', 'NAME', 'MAIL', '0', 'NAME');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'nickname', 'NAME');

How to run only if there is no user with same username?

I'm trying with select in place of values, as they speak in several sql topics, type this: https://stackoverflow.com/questions/3164505/mysql-insert-record-if-not-exists-in-table But I can not.

Is it possible to update if exists or insert if it does not exist in wordpress?

Or is there any way to manage users of hundreds of Wordpress sites from one place?

  • Why not use the WordPress API? – birgire Jan 31 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.