| 1 |
<?php |
| 2 |
/************************************************************* |
| 3 |
* |
| 4 |
* user.class.php |
| 5 |
* |
| 6 |
* Add Users |
| 7 |
* |
| 8 |
* |
| 9 |
* Copyright (c) 2011 Prelovac Media |
| 10 |
* www.prelovac.com |
| 11 |
**************************************************************/ |
| 12 |
|
| 13 |
class MMB_User extends MMB_Core |
| 14 |
{ |
| 15 |
function __construct() |
| 16 |
{ |
| 17 |
parent::__construct(); |
| 18 |
} |
| 19 |
|
| 20 |
function add_user($args) |
| 21 |
{ |
| 22 |
|
| 23 |
if(!function_exists('username_exists') || !function_exists('email_exists')) |
| 24 |
include_once(ABSPATH . WPINC . '/registration.php'); |
| 25 |
|
| 26 |
if(username_exists($args['user_login'])) |
| 27 |
return array('error' => 'Username already exists'); |
| 28 |
|
| 29 |
if (email_exists($args['user_email'])) |
| 30 |
return array('error' => 'Email already exists'); |
| 31 |
|
| 32 |
if(!function_exists('wp_insert_user')) |
| 33 |
include_once (ABSPATH . 'wp-admin/includes/user.php'); |
| 34 |
|
| 35 |
$user_id = wp_insert_user($args); |
| 36 |
|
| 37 |
if($user_id){ |
| 38 |
|
| 39 |
if($args['email_notify']){ |
| 40 |
//require_once ABSPATH . WPINC . '/pluggable.php'; |
| 41 |
wp_new_user_notification($user_id, $args['user_pass']); |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
return $user_id; |
| 46 |
}else{ |
| 47 |
return array('error' => 'User not added. Please try again.'); |
| 48 |
} |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
} |
| 53 |
?> |