Ejemplo n.º 1
0
 public static function do_reset_content_user_password($user_name)
 {
     // 1. Verify that the user name exists in the system
     $user_party_data = EntityAPI::get_by_field('party', 'user_name', $user_name);
     if (!isset($user_party_data['id'])) {
         return array('has_errors' => true, 'message' => "Sorry the username you provided is not registered");
     }
     // 2. Load the person associated with the party
     $user_person_data = EntityAPI::get_by_field('person', 'person_party', $user_party_data['id']);
     if (!isset($user_person_data['id'])) {
         return array('has_errors' => true, 'message' => "Sorry could not load the data for specified individual");
     }
     // Build the content user data
     $content_user_data = array('user_pass' => SecurityAPI::generate_password(), 'last_name' => $user_person_data['last_name'], 'first_name' => $user_person_data['first_name'], 'user_login' => $user_party_data['user_name']);
     MailAPI::do_send_user_password_email($content_user_data, array());
     return array('has_errors' => false, 'content_user' => $content_user_data);
 }
 public static function do_create_content_user($content_user_data, $send_email_flag)
 {
     if (!self::validate_user_data($content_user_data)) {
         return EntityAPIUtils::init_error($content_user_data, 'Invalid user sign up data');
     }
     // Only insert if the user does not exist
     $user = get_user_by('login', $content_user_data['user_login']);
     if (!$user) {
         $user_id = wp_insert_user($content_user_data);
         if (is_wp_error($user_id)) {
             return array('has_errors' => true, 'message' => $user_id->get_error_message());
         }
     }
     $user_party_data = self::create_individual($content_user_data);
     if ($user_party_data['has_errors']) {
         return $user_party_data;
     }
     if ($send_email_flag) {
         MailAPI::do_send_user_created_email($content_user_data, array());
     }
     return $user_party_data;
 }