Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function custom_login() {
- $creds = array();
- $creds['user_login'] = 'example';
- $creds['user_password'] = 'plaintextpw';
- $creds['remember'] = true;
- $user = wp_signon( $creds, false );
- if ( is_wp_error($user) )
- echo $user->get_error_message();
- }
- // run it before the headers and cookies are sent
- add_action( 'after_setup_theme', 'custom_login' );
- $user_id = username_exists( $user_name );
- if ( !$user_id and email_exists($user_email) == false ) {
- $random_password = wp_generate_password( $length=12,
- $include_standard_special_chars=false );
- $user_id = wp_create_user( $user_name, $random_password, $user_email );
- } else {
- $random_password = __('User already exists. Password inherited.');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement