[ 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( array( 'user_id' => $user_to_make_admin->ID, 'action' => 'admin' ) ) ) {
  20                  /* translators: %s: Username */
  21                  WP_CLI::error( sprintf( __( "Error in making '%s' an admin.", 'glotpress' ), $user_login ) );
  22              }
  23  
  24              /* translators: %s: Username */
  25              WP_CLI::line( sprintf( __( "'%s' is now an admin.", 'glotpress' ), $user_login ) );
  26          }
  27      }
  28  }


Generated: Sun Nov 17 01:01:56 2019 Cross-referenced by PHPXref 0.7.1