Advertisement
chrmrtns

Wordpress_New_Admin

Dec 7th, 2021 (edited)
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /*
  5.  * Plugin Name: CHRMRTNS Create new Admin
  6.  * Description: Creates a new admin in Wordpress
  7.  * License:     GPL v2 or later
  8.  * License URI: https://www.gnu.org/licenses/gpl-2.0.html
  9.  */
  10.  
  11.  
  12. /* Create new admin in Wordpress
  13. *
  14. *  Add this to your custom functions.php or to
  15. *  your custom plugin to update Wordpress admins
  16. *
  17. */
  18.  
  19.  
  20. /*
  21.  * Define new administrator
  22. */
  23.  
  24. function chrmrtns_add_admin_acct(){
  25.     $login = 'mycustomuserlogin';
  26.     $passw = '12345';
  27.     $email = 'test@example.com';
  28.  
  29.     if ( !username_exists( $login )  && !email_exists( $email ) ) {
  30.         $user_id = wp_create_user( $login, $passw, $email );
  31.         $user = new WP_User( $user_id );
  32.         $user->set_role( 'administrator' );
  33.     }
  34. }
  35. add_action('init','chrmrtns_add_admin_acct');
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement