Vytvorenie účtu cez FTP
/* vytvorenie admin uctu cez ftp
pridat do function.php v child-teme, hned po tom vymazat
MENO, EMAIL, HESLO zadať vlastné
*/
function moj_admin_account(){
$user = 'MENO';
$pass = 'HESLO';
$email = 'EMAIL';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user-> set_role( 'administrator' );
}
}
add_action('init','moj_admin_account');
Vymazanie účtu cez FTP
/* vymazanie aj admin uctu cez ftp
pridat do function.php v child-teme, hned po tom vymazat
*/
function delete_user( $user_id ) {
//Include the user file with the user administration API
require_once( ABSPATH . 'wp-admin/includes/user.php' );
//Delete a WordPress user by specifying its user ID. Here the user with an ID equal to $user_id is deleted.
return wp_delete_user( $user_id );
}
//Delete the user with ID equal to 3
delete_user(3);
Zistenie ID, mena a emailu užívateľa
add_action( 'wp_footer', 'dopln_footer' );
function dopln_footer() {
echo 'ID uzivatela: ';
echo get_current_user_id() ;
global $current_user;
echo $current_user->user_login;
echo $current_user->user_email;
}