Answers for "global user wordpress"

PHP
1

How to create WordPress users programmatically

<?php
  global $wpdb;
 $user_id = wp_insert_user( array(
  'user_login' => "sn1",
  'user_pass' => "passwordgoeshere",
  'user_email' => "[email protected]",
  'first_name' => "sn1",
  'last_name' => 'sn1',
  'display_name' => 'sn1 sn1',
  'role' => 'editor'
));

function wp_create_users() { 
/////$meta value is store in to wp_usermeta table in database///
  $meta = array(
    'job_title' => 'developer',
    'country' => 'United States',
    'viaphp' => true
  );
 //////create user //////
    $user_login = wp_slash( "sn1" );
    $user_email = wp_slash("[email protected]" );
    $user_pass  = "passwordgoeshere";
     $userdata = compact( 'user_login', 'user_email', 'user_pass' );
    return wp_insert_user( $userdata );
  }register_activation_hook(__FILE__, 'wp_create_users' );
?>
Posted by: Guest on January-25-2021
0

create wordpress user programatically

function my_create_user() {
	$user  = '*** username ***';
	$pass  = '*** password ***';
	$email = '*** [email protected]  ***';
	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' ); // Set user role ('editor', 'customer', 'subscriber', etc) More roles: https://wordpress.org/support/article/roles-and-capabilities/#summary-of-roles
	}
}
add_action('init', 'my_create_user');
Posted by: Guest on May-21-2021
0

logout all the users from site wordpress

Generate new salt and key for wordpress and replace with the old one which will
forcefully logout all the logged in users.
https://api.wordpress.org/secret-key/1.1/salt/

https://www.greengeeks.in/tutorials/article/completely-force-logout-users-wordpress/#:~:text=Using%20the%20WPForce%20Logout%20Plugin&text=Then%20in%20the%20%E2%80%9CBulk%20Actions,%E2%80%9CLogout%20All%20Users%E2%80%9D%20button.
Posted by: Guest on March-31-2021

Browse Popular Code Answers by Language