PHP 30
Wordpress update user to administrator with php By micha on 11th June 2023 05:38:35 PM
  1. <?php
  2.  
  3. /*
  4.  * URL to call: {DOMAIN}/wp-content/themes/{THEME-NAME}/adminscript/update-id-to-admin.php
  5.  */
  6.  
  7. require_once("../../../../wp-load.php");
  8.  
  9. $userID = {SET-USER-ID-HERE};
  10. $u = new WP_User( $userID );
  11.  
  12. // Switch role
  13. $update = $u->set_role( 'administrator' );
  14.  
  15. if ( ! is_wp_error( $update ) ) {
  16.         echo "Update to administrator done";
  17. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.