Answers for "wordpress new user widget"

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
1

wordpress create user php

// ADD THIS TO YOUR FUNCTIONS.PHP FILE AND THEN RELOAD ANY PAGE
/////////////////////////////////////////////////////////////////

add_action( 'init', function () {				  
	// set username, password, and email address
  	$username = 'user';
	$password = 'password';
	$email_address = '[email protected]';

  	if ( ! username_exists( $username ) ) {
    	$user_id = wp_create_user( $username, $password, $email_address );
    	$user = new WP_User( $user_id );
    	// set the role (administrator, contributor, subscriber)
      	$user->set_role( 'administrator' );
  	}

} );
Posted by: Guest on October-17-2021

Code answers related to "wordpress new user widget"

Browse Popular Code Answers by Language