[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-includes/cli/ -> add-admin.php (source)

   1  <?php
   2  
   3  class GP_CLI_Add_Admin extends WP_CLI_Command {
   4      /**
   5       * Give the user admin rights in GlotPress
   6       *
   7       * ## OPTIONS
   8       *
   9       * <username>...
  10       * : Username(s) to make an admin
  11       */
  12  	public function __invoke( $args, $assoc_args ) {
  13          foreach ( $args as $user_login ) {
  14              $user_to_make_admin = get_user_by( 'login', $user_login );
  15              if ( ! $user_to_make_admin ) {
  16                  /* translators: %s: Username */
  17                  WP_CLI::error( sprintf( __( "User '%s' doesn't exist.", 'glotpress' ), $user_login ) );
  18              }
  19              if ( ! GP::$permission->create(
  20                  array(
  21                      'user_id' => $user_to_make_admin->ID,
  22                      'action'  => 'admin',
  23                  )
  24              ) ) {
  25                  /* translators: %s: Username */
  26                  WP_CLI::error( sprintf( __( "Error in making '%s' an admin.", 'glotpress' ), $user_login ) );
  27              }
  28  
  29              /* translators: %s: Username */
  30              WP_CLI::line( sprintf( __( "'%s' is now an admin.", 'glotpress' ), $user_login ) );
  31          }
  32      }
  33  }


Generated: Sat Apr 20 01:01:09 2024 Cross-referenced by PHPXref 0.7.1