Přidat uživatele s administrátorskými právy pomocí PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet Přidání uživatele s administrátorskými právy. Obsah souboru ideálně vložte do mu-plugins/add-admin-user.php a po vytvoření uživatele odstraňte z vwebu. | |
* @source https://kybernaut.cz/?p=3070 | |
* @author Karolína Vyskočilová (https://kybernaut.cz) | |
* @testedwith WordPress 5.3 | |
*/ | |
add_action( 'init', function () { | |
$uzivatelske_jmeno = 'admin'; | |
$heslo = 'mojeheslo'; | |
$email = 'ja@domain.com'; | |
if ( ! username_exists( $uzivatelske_jmeno ) ) { | |
$user_id = wp_create_user( $uzivatelske_jmeno, $heslo, $email ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment