public function json_create_user()
 {
     $error = array("status" => 0, "msg" => __('There has been an error processing your request. Please, reload the page and try again.', Eab_EventsHub::TEXT_DOMAIN));
     $data = stripslashes_deep($_POST);
     $email = $data['email'];
     if (empty($email)) {
         $error['msg'] = __('Please, submit an email.', Eab_EventsHub::TEXT_DOMAIN);
         die(json_encode($error));
     }
     if (!is_email($email)) {
         $error['msg'] = __('Please, submit a valid email.', Eab_EventsHub::TEXT_DOMAIN);
         die(json_encode($error));
     }
     if (email_exists($email)) {
         $current_location = get_permalink();
         if (!empty($data['location'])) {
             // Let's make this sane first - it's coming from a POST request, so make that sane
             $loc = wp_validate_redirect(wp_sanitize_redirect($data['location']));
             if (!empty($loc)) {
                 $current_location = $loc;
             }
         }
         $login_link = wp_login_url($current_location);
         $login_message = sprintf(__('The email address already exists. Please <a href="%s">Login</a> and RSVP to the event.', Eab_EventsHub::TEXT_DOMAIN), $login_link);
         $error['msg'] = $login_message;
         die(json_encode($error));
     }
     $wordp_user = $this->_create_user($email);
     if (is_object($wordp_user) && !empty($wordp_user->ID)) {
         $this->_login_user($wordp_user);
     } else {
         die(json_encode($error));
     }
     die(json_encode(array("status" => 1)));
 }
function ct_validate_email_ajaxlogin($email = null, $is_ajax = true)
{
    require_once CLEANTALK_PLUGIN_DIR . 'cleantalk-public.php';
    global $ct_agent_version, $ct_checkjs_register_form, $ct_session_request_id_label, $ct_session_register_ok_label, $bp, $ct_signup_done, $ct_formtime_label, $ct_negative_comment, $ct_options, $ct_data;
    $ct_options = ct_get_options();
    $ct_data = ct_get_data();
    $email = is_null($email) ? $email : $_POST['email'];
    $email = sanitize_email($email);
    $is_good = true;
    if (!filter_var($email, FILTER_VALIDATE_EMAIL) || email_exists($email)) {
        $is_good = false;
    }
    if (class_exists('AjaxLogin') && isset($_POST['action']) && $_POST['action'] == 'validate_email') {
        $ct_options = ct_get_options();
        $checkjs = js_test('ct_checkjs', $_COOKIE, true);
        $submit_time = submit_time_test();
        $sender_info = get_sender_info();
        $sender_info['post_checkjs_passed'] = $checkjs;
        if ($checkjs === null) {
            $checkjs = js_test('ct_checkjs', $_COOKIE, true);
            $sender_info['cookie_checkjs_passed'] = $checkjs;
        }
        $sender_info = json_encode($sender_info);
        if ($sender_info === false) {
            $sender_info = '';
        }
        require_once 'cleantalk.class.php';
        $config = get_option('cleantalk_server');
        $ct = new Cleantalk();
        $ct->work_url = $config['ct_work_url'];
        $ct->server_url = $ct_options['server'];
        $ct->server_ttl = $config['ct_server_ttl'];
        $ct->server_changed = $config['ct_server_changed'];
        $ct->ssl_on = $ct_options['ssl_on'];
        $ct_request = new CleantalkRequest();
        $ct_request->auth_key = $ct_options['apikey'];
        $ct_request->sender_email = $email;
        $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
        $ct_request->sender_nickname = '';
        $ct_request->agent = $ct_agent_version;
        $ct_request->sender_info = $sender_info;
        $ct_request->js_on = $checkjs;
        $ct_request->submit_time = $submit_time;
        $ct_result = $ct->isAllowUser($ct_request);
        if ($ct->server_change) {
            update_option('cleantalk_server', array('ct_work_url' => $ct->work_url, 'ct_server_ttl' => $ct->server_ttl, 'ct_server_changed' => time()));
        }
        if ($ct_result->allow === 0) {
            $is_good = false;
        }
    }
    if ($is_good) {
        $ajaxresult = array('description' => null, 'cssClass' => 'noon', 'code' => 'success');
    } else {
        $ajaxresult = array('description' => 'Invalid Email', 'cssClass' => 'error-container', 'code' => 'error');
    }
    $ajaxresult = json_encode($ajaxresult);
    print $ajaxresult;
    wp_die();
}
function registrar_usuario($parametros)
{
    $errors = new WP_Error();
    if ($parametros['email'] == NULL) {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
        return $errors;
    }
    if (!es_email($parametros['email'])) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
        return $errors;
    }
    if (email_exists($parametros['email'])) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
        return $errors;
    }
    if ($parametros['nombre'] == NULL) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
        return $errors;
    }
    $user_pass = $parametros['clave'] == NULL ? wp_generate_password(12, false) : $parametros['clave'];
    $user_id = wp_create_user($parametros['email'], $user_pass, $parametros['email']);
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
        return $errors;
    }
    update_user_option($user_id, 'default_password_nag', true, true);
    //Set up the Password change nag.
    wp_new_user_notification($user_id, $user_pass);
    // Actualización de tabla clientes...
    return $user_id;
}
Esempio n. 4
0
function fu_add_new_user($fu = false)
{
    //echo "wtf?";
    require_once '../../../wp-includes/registration.php';
    global $blog_id;
    $email = sanitize_email($fu['email']);
    //$current_site = get_current_site();
    $pass = $fu['password'];
    $user_id = email_exists($email);
    //echo "hi";
    if (!$user_id) {
        $password = $pass ? $pass : generate_random_password();
        $user_id = wpmu_create_user($fu['username'], $password, $email);
        if (false == $user_id) {
            //echo "uh oh";
            wp_die(__('There was an error creating the user'));
        } else {
            //echo "sending mail";
            wp_new_user_notification($user_id, $password);
        }
        if (get_user_option('primary_blog', $user_id) == $blog_id) {
            update_user_option($user_id, 'primary_blog', $blog_id, true);
        }
    }
    $redirect = $fu['referer'] ? $fu['referer'] : get_bloginfo('url');
    wp_redirect($redirect);
}
Esempio n. 5
0
 function registra_usuario($username, $password, $email)
 {
     global $db;
     if (user_exists($username)) {
         $mensaje_de_error = "El usuario " . $username . " ya existe";
     } else {
         if (check_email($email) == 0) {
             $mensaje_de_error = "El mail no es válido";
         } else {
             if (email_exists($email)) {
                 $mensaje_de_error = "El mail " . $email . " ya existe";
             } else {
                 $SELECT = "INSERT INTO usuarios ( usuario_login, usuario_password, usuario_email, usuario_nombre )";
                 $SELECT .= " VALUES ( '" . $username . "', '" . md5($password) . "', '" . $email . "', '" . $username . "' )";
                 $result = $db->get_results($SELECT);
                 logea("registro " . $username, "", $_SESSION["usuario"]);
                 //Creamos el ranking con un día atrás para que no obtenga beneficios de 60000 al actualizar el ranking hoy
                 $SELECT = "INSERT INTO ranking ( ranking_usuario, ranking_saldo, ranking_invertido, ranking_total, ranking_beneficio_hoy, ranking_fecha ) ";
                 $SELECT .= " VALUES ( '" . $username . "', '60000', '0', '60000', '0', CURDATE()-INTERVAL 1 DAY )";
                 $result = $db->get_results($SELECT);
             }
         }
     }
     return $mensaje_de_error;
 }
Esempio n. 6
0
 private function __user_exists_check($data)
 {
     // check if user exists in WP or DB
     $return = array('user' => false);
     if (isset($data['user_email'])) {
         $email_check = email_exists($data['user_email']);
         if ($email_check) {
             $db_user = $this->__user_db_check($data['social_id']);
             if (!$db_user) {
                 $this->__create_user_db($email_check, $data['social_id']);
             }
             $return['user'] = get_user_by('id', $email_check);
         }
     }
     if (isset($data['social_id']) && $return['user'] == false) {
         $db_user = $this->__user_db_check($data['social_id']);
         if ($db_user) {
             $return['user'] = get_user_by('id', $db_user->wp_user_id);
         }
     }
     if (!isset($data['social_id']) && !isset($data['user_email'])) {
         return new WP_Error('No Data', __('Expecting social_id or user_email'), array('status' => 400));
     }
     return $return;
 }
 /** Return true if supplied email is valid or give an error message otherwise */
 static function is_email_does_not_exist($e)
 {
     if (email_exists($e)) {
         return __('Já existe um usuário com o e-mail informado');
     }
     return true;
 }
  /**
   * Return user data in JSON format
   *
   * @todo add hooks to accomodate different user values
   * @since 3.0
   *
   */
  function get_user_date($user_email = false) {
    global $wpdb;

      if(!$user_email) {
        return;
      }

      $user_id = email_exists($user_email);

      if(!$user_id) {
        return;
      }

      $user_data['first_name'] = get_user_meta($user_id, 'first_name', true);
      $user_data['last_name'] = get_user_meta($user_id, 'last_name', true);
      $user_data['company_name'] = get_user_meta($user_id, 'company_name', true);
      $user_data['phonenumber'] = get_user_meta($user_id, 'phonenumber', true);
      $user_data['streetaddress'] = get_user_meta($user_id, 'streetaddress', true);
      $user_data['city'] = get_user_meta($user_id, 'city', true);
      $user_data['state'] = get_user_meta($user_id, 'state', true);
      $user_data['zip'] = get_user_meta($user_id, 'zip', true);

      if($user_data) {
        echo json_encode(array('succes' => 'true', 'user_data' => $user_data));
      }

  }
Esempio n. 9
0
function registration_validation($username, $password, $email)
{
    global $reg_errors;
    $reg_errors = new WP_Error();
    if (empty($username) || empty($password) || empty($email)) {
        $reg_errors->add('field', 'Required form field is missing');
    }
    if (4 > strlen($username)) {
        $reg_errors->add('username_length', 'Username too short. At least 4 characters is required');
    }
    if (username_exists($username)) {
        $reg_errors->add('user_name', 'Sorry, that username already exists!');
    }
    if (!validate_username($username)) {
        $reg_errors->add('username_invalid', 'Sorry, the username you entered is not valid');
    }
    if (5 > strlen($password)) {
        $reg_errors->add('password', 'Password length must be greater than 5');
    }
    if (!is_email($email)) {
        $reg_errors->add('email_invalid', 'Email is not valid');
    }
    if (email_exists($email)) {
        $reg_errors->add('email', 'Email Already in use');
    }
    if (is_wp_error($reg_errors)) {
        foreach ($reg_errors->get_error_messages() as $error) {
            echo '<div>';
            echo '<strong>ERROR</strong>:';
            echo $error . '<br/>';
            echo '</div>';
        }
    }
}
Esempio n. 10
0
 function upme_replace_avatar($avatar, $id_or_email, $size, $default, $alt)
 {
     // Optimized condition and added strict conditions
     if (is_numeric($id_or_email)) {
         $user_id = $id_or_email;
     } else {
         if (is_object($id_or_email)) {
             $user_id = email_exists($id_or_email->comment_author_email);
         } else {
             $user_id = email_exists($id_or_email);
         }
     }
     echo '<pre>';
     print_r($user_id);
     echo '</pre>';
     exit;
     // Filter default gravatars to prvent the loading of custom profile image
     $default_gravatars = array("blank", "identicon", "wavatar", "monsterid", "retro");
     if ($user_id > 0 && !in_array($default, $default_gravatars)) {
         if (get_the_author_meta('user_pic', $user_id) != '') {
             if (!isset($size) || $size == '0') {
                 $size = 60;
             }
             $avatar = '<img src="' . get_the_author_meta('user_pic', $user_id) . '" alt="" width="' . $size . '" height="' . $size . '" class="avatar avatar-' . $size . ' photo">';
         }
     }
     /* UPME Filter for customizing avatar image on profiles */
     $avatar = apply_filters('upme_replace_avatar', $avatar, $user_id);
     // End Filter
     return $avatar;
 }
Esempio n. 11
0
function pn_create_user($user_name, $user_email, $first_name, $last_name, $title)
{
    require_once ABSPATH . WPINC . '/pluggable.php';
    //WP v3.0.1 - wp_generate_password
    require_once ABSPATH . WPINC . '/registration.php';
    //WP v3.0.1 - username_exists, email_exists
    if (email_exists($user_email)) {
        return false;
    }
    $user_id = username_exists($user_name);
    if (!$user_id) {
        $random_password = wp_generate_password(12, false);
        $user_role = get_option('pn_register_role') ? get_option('pn_register_role') : 'subscriber';
        $new_user = array();
        $new_user['user_pass'] = $random_password;
        $new_user['user_login'] = $user_name;
        $new_user['user_email'] = $user_email;
        $new_user['display_name'] = $title . ' ' . $first_name . ' ' . $last_name;
        $new_user['first_name'] = $first_name;
        $new_user['last_name'] = $last_name;
        $new_user['role'] = $user_role;
        if ($id = wp_insert_user($new_user)) {
            return $random_password;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Esempio n. 12
0
/**
 * Adds a new client from the event field.
 *
 * @since	1.3.7
 * @global	arr		$_POST
 */
function mdjm_add_client_ajax()
{
    $client_id = false;
    $client_list = '';
    $result = array();
    $message = array();
    if (!is_email($_POST['client_email'])) {
        $message[] = __('Email address is invalid', 'mobile-dj-manager');
    } elseif (email_exists($_POST['client_email'])) {
        $message[] = __('Email address is already in use', 'mobile-dj-manager');
    } else {
        $user_data = array('first_name' => ucwords($_POST['client_firstname']), 'last_name' => !empty($_POST['client_lastname']) ? ucwords($_POST['client_lastname']) : '', 'user_email' => $_POST['client_email'], 'client_phone' => !empty($_POST['client_phone']) ? $_POST['client_phone'] : '', 'client_phone2' => !empty($_POST['client_phone2']) ? $_POST['client_phone2'] : '');
        $user_data = apply_filters('mdjm_event_new_client_data', $user_data);
        $client_id = mdjm_add_client($user_data);
    }
    $clients = mdjm_get_clients('client');
    if (!empty($clients)) {
        foreach ($clients as $client) {
            $client_list .= sprintf('<option value="%1$s"%2$s>%3$s</option>', $client->ID, $client->ID == $client_id ? ' selected="selected"' : '', $client->display_name);
        }
    }
    if (empty($client_id)) {
        $result = array('type' => 'error', 'message' => explode("\n", $message));
    } else {
        $result = array('type' => 'success', 'client_id' => $client_id, 'client_list' => $client_list);
        do_action('mdjm_after_add_new_client', $user_data);
    }
    echo json_encode($result);
    die;
}
Esempio n. 13
0
 /**
  *  Mot de passe oublié (partie 1)
  *  @author Cam
  *  @return tpl
  */
 protected function main()
 {
     // Si le membre est déjà connecté
     if (is_logged_in()) {
         redir(Nw::$lang['common']['already_connected'], false, './');
     }
     $this->set_title(Nw::$lang['users']['title_lost_pwd']);
     $this->set_tpl('membres/oubli_mdp.html');
     $this->add_css('forms.css');
     // Fil ariane
     $this->set_filAriane(Nw::$lang['users']['title_lost_pwd']);
     //Si le formulaire a été validé
     if (isset($_POST['submit'])) {
         // Cette adresse email existe bien sur le site
         inc_lib('users/email_exists');
         if (email_exists($_POST['mail'])) {
             //On récupère les infos du membre
             inc_lib('users/get_info_mbr');
             $membre_mail = get_info_mbr($_POST['mail'], 'mail');
             $lien_password = Nw::$site_url . 'users-13.html?idm=' . $membre_mail['u_id'] . '&ca=' . $membre_mail['u_code_act'];
             //On prépare le texte de l'email
             $txt_mail = sprintf(Nw::$lang['users']['mail_oubli_pwd'], $membre_mail['u_pseudo'], $lien_password, $lien_password, $lien_password);
             @envoi_mail(trim($_POST['mail']), sprintf(Nw::$lang['users']['title_mail_lost_pwd'], Nw::$site_name), $txt_mail);
             redir(Nw::$lang['users']['send_mail_lost'], true, './');
         } else {
             redir(Nw::$lang['users']['email_aucun_mbr'], false, 'users-12.html');
         }
     }
 }
Esempio n. 14
0
 /**
  * Filter for get_avatar. Allow to change degault avatar to custom one.
  * 
  * @param type $avatar
  * @param type $id_or_email
  * @param type $size
  * @param type $default
  * @param type $alt
  * @return html img tag
  */
 function getAvatar($avatar = '', $id_or_email, $size = '96', $default = '', $alt = false)
 {
     global $userMeta;
     $safe_alt = false === $alt ? '' : esc_attr($alt);
     if (is_numeric($id_or_email)) {
         $user_id = (int) $id_or_email;
     } elseif (is_string($id_or_email)) {
         $user_id = email_exists($id_or_email);
     } elseif (is_object($id_or_email)) {
         if (!empty($id_or_email->user_id)) {
             $user_id = (int) $id_or_email->user_id;
         } elseif (!empty($id_or_email->comment_author_email)) {
             $user_id = email_exists($id_or_email->comment_author_email);
         }
     }
     if (!isset($user_id)) {
         return $avatar;
     }
     $umAvatar = get_user_meta($user_id, 'user_avatar', true);
     $file = $userMeta->determinFileDir($umAvatar);
     if (!empty($file)) {
         $avatar = "<img alt='{$safe_alt}' src='{$file['url']}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
     }
     return $avatar;
 }
function seed_cspv4_emaillist_followupemails_queue_email()
{
    global $wpdb, $seed_cspv4, $seed_cspv4_post_result;
    extract($seed_cspv4);
    require_once SEED_CSPV4_PLUGIN_PATH . 'lib/nameparse.php';
    $name = '';
    if (!empty($_REQUEST['name'])) {
        $name = $_REQUEST['name'];
    }
    $email = strtolower($_REQUEST['email']);
    $fname = '';
    $lname = '';
    if (!empty($name)) {
        $name = seed_cspv4_parse_name($name);
        $fname = $name['first'];
        $lname = $name['last'];
    }
    if (email_exists($email)) {
        // Subscriber already exist show stats
        $seed_cspv4_post_result['status'] = '200';
        $seed_cspv4_post_result['msg'] = $txt_already_subscribed_msg;
        $seed_cspv4_post_result['msg_class'] = 'alert-info';
        $seed_cspv4_post_result['clicks'] = '0';
    } else {
        $user_id = wp_insert_user(array('user_login' => $email, 'user_email' => $email, 'first_name' => $fname, 'last_name' => $lname, 'user_pass' => wp_generate_password()));
        if (empty($seed_cspv4_post_result['status'])) {
            $seed_cspv4_post_result['status'] = '200';
        }
    }
}
function acxu_createUser($args)
{
    global $wp_xmlrpc_server;
    $wp_xmlrpc_server->escape($args);
    $nickname = $args[0];
    //$password = $args[1];
    //if ( ! $user = $wp_xmlrpc_server->login( $username, $password ) )
    //    return $wp_xmlrpc_server->error;
    $user_name = time() . "_" . rand(1000, 9999);
    $user_email = $user_name . "@bbuser.org";
    if (!username_exists($user_name) && !email_exists($user_email)) {
        $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
        $user_id = wp_create_user($user_name, $random_password, $user_email);
        if ($nickname == "") {
            $nickname = $user_email;
        }
        // Update the user to set the nickname
        wp_update_user(array('ID' => $user_id, 'nickname' => $nickname));
        // Get the user object to set the user's role
        $wp_user_object = new WP_User($user_id);
        //http://en.support.wordpress.com/user-roles/
        $wp_user_object->set_role('author');
        return $user_name . " " . $random_password;
    } else {
        return "ERROR: User Name or Email Already Exists";
    }
}
function um_submit_account_errors_hook($args)
{
    global $ultimatemember;
    // errors on general tab
    if (isset($_POST['um_account_submit']) && $_POST['um_account_submit'] != __('Delete Account', 'ultimatemember')) {
        if (isset($_POST['first_name']) && strlen(trim($_POST['first_name'])) == 0) {
            $ultimatemember->form->add_error('first_name', __('You must provide your first name', 'ultimatemember'));
        }
        if (isset($_POST['last_name']) && strlen(trim($_POST['last_name'])) == 0) {
            $ultimatemember->form->add_error('last_name', __('You must provide your last name', 'ultimatemember'));
        }
        if (isset($_POST['user_email']) && strlen(trim($_POST['user_email'])) == 0) {
            $ultimatemember->form->add_error('user_email', __('You must provide your e-mail', 'ultimatemember'));
        }
        if (isset($_POST['user_email']) && !is_email($_POST['user_email'])) {
            $ultimatemember->form->add_error('user_email', __('Please provide a valid e-mail', 'ultimatemember'));
        }
        if (email_exists($_POST['user_email']) && email_exists($_POST['user_email']) != get_current_user_id()) {
            $ultimatemember->form->add_error('user_email', __('Email already linked to another account', 'ultimatemember'));
        }
    }
    $ultimatemember->account->current_tab = 'general';
    // change password
    if ($_POST['current_user_password'] != '') {
        if (!wp_check_password($_POST['current_user_password'], um_user('user_pass'), um_user('ID'))) {
            $ultimatemember->form->add_error('current_user_password', __('This is not your password', 'ultimatemember'));
            $ultimatemember->account->current_tab = 'password';
        } else {
            // correct password
            if ($_POST['user_password'] != $_POST['confirm_user_password'] && $_POST['user_password']) {
                $ultimatemember->form->add_error('user_password', __('Your new password does not match', 'ultimatemember'));
                $ultimatemember->account->current_tab = 'password';
            }
            if (um_get_option('account_require_strongpass')) {
                if (strlen(utf8_decode($_POST['user_password'])) < 8) {
                    $ultimatemember->form->add_error('user_password', __('Your password must contain at least 8 characters', 'ultimatemember'));
                }
                if (strlen(utf8_decode($_POST['user_password'])) > 30) {
                    $ultimatemember->form->add_error('user_password', __('Your password must contain less than 30 characters', 'ultimatemember'));
                }
                if (!$ultimatemember->validation->strong_pass($_POST['user_password'])) {
                    $ultimatemember->form->add_error('user_password', __('Your password must contain at least one lowercase letter, one capital letter and one number', 'ultimatemember'));
                    $ultimatemember->account->current_tab = 'password';
                }
            }
        }
    }
    // delete account
    if (isset($_POST['um_account_submit']) && $_POST['um_account_submit'] == __('Delete Account', 'ultimatemember')) {
        if (strlen(trim($_POST['single_user_password'])) == 0) {
            $ultimatemember->form->add_error('single_user_password', __('You must enter your password', 'ultimatemember'));
        } else {
            if (!wp_check_password($_POST['single_user_password'], um_user('user_pass'), um_user('ID'))) {
                $ultimatemember->form->add_error('single_user_password', __('This is not your password', 'ultimatemember'));
            }
        }
        $ultimatemember->account->current_tab = 'delete';
    }
}
 /**
  * Validate username field.
  *
  * @access public
  * @since 1.0.0
  * @return void
  */
 public static function validate_username($passed, $fields, $values)
 {
     $username = $values['user']['username_email'];
     if (is_email($username) && !email_exists($username) || !is_email($username) && !username_exists($username)) {
         return new WP_Error('username-validation-error', __('This user could not be found.', 'wpum'));
     }
     return $passed;
 }
Esempio n. 19
0
function aitAddNewClaim()
{
    if (defined('AIT_SERVER')) {
        return 0;
    }
    if (!empty($_POST['itemId']) && !empty($_POST['username']) && !empty($_POST['name']) && !empty($_POST['email'])) {
        // check username and email if exist
        if (username_exists($_POST['username'])) {
            _e("This username is already registered. Please choose another one.", "ait");
            exit;
        }
        if (email_exists($_POST['email'])) {
            _e("This email is already registered, please choose another one.", "ait");
            exit;
        }
        global $aitThemeOptions;
        // Check for nonce security
        $nonce = $_POST['nonce'];
        if (!wp_verify_nonce($nonce, 'ajax-nonce')) {
            _e('Bad nonce', 'ait');
            exit;
        }
        $claim = array('post_title' => $_POST['username'], 'post_content' => $_POST['message'], 'post_type' => 'ait-claim', 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed');
        $claimId = wp_insert_post($claim);
        if ($claimId == 0) {
            return 0;
        }
        update_post_meta($claimId, 'item_id', $_POST['itemId']);
        update_post_meta($claimId, 'username', $_POST['username']);
        update_post_meta($claimId, 'name', $_POST['name']);
        update_post_meta($claimId, 'email', $_POST['email']);
        update_post_meta($claimId, 'number', $_POST['number']);
        update_post_meta($claimId, 'status', 'new');
        // send email to admin
        if (isset($aitThemeOptions->directory->claimAdminEmail)) {
            $to = get_option('admin_email');
            $subject = strip_tags($aitThemeOptions->directory->claimAdminEmailSubject);
            $postLink = get_permalink(intval($_POST['itemId']));
            $post = get_post(intval($_POST['itemId']));
            $bodyHtml = $aitThemeOptions->directory->claimAdminEmailBody;
            $bodyHtml = str_replace('[item]', '<a href="' . $postLink . '" target="_blank">' . $post->post_title . '</a>', $bodyHtml);
            $bodyHtml = str_replace('[name]', $_POST['name'], $bodyHtml);
            $bodyHtml = str_replace('[username]', $_POST['username'], $bodyHtml);
            $bodyHtml = str_replace('[email]', $_POST['email'], $bodyHtml);
            $bodyHtml = str_replace('[phone]', $_POST['number'], $bodyHtml);
            $bodyHtml = str_replace('[message]', $_POST['message'], $bodyHtml);
            $bodyHtml = str_replace('[link]', admin_url('/edit.php?post_type=ait-claim'), $bodyHtml);
            $headers = 'From: ' . $aitThemeOptions->directory->claimAdminEmailFrom . "\r\n";
            add_filter('wp_mail_content_type', 'aitSetHtmlMail');
            wp_mail($to, $subject, $bodyHtml, $headers);
            remove_filter('wp_mail_content_type', 'aitSetHtmlMail');
        }
        echo "success";
    } else {
        _e("Please fill out inputs", "ait");
    }
    exit;
}
/**
* Checks whether the given email exists in WordPress users tables.
*
* This function is not loaded by default in wp 3.0
*
* https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/user.php#L1565
*/
function wsl_wp_email_exists($email)
{
    if (function_exists('email_exists')) {
        return email_exists($email);
    }
    if ($user = get_user_by('email', $email)) {
        return $user->ID;
    }
}
Esempio n. 21
0
 public function registration($userdata)
 {
     $reg_errors = new WP_Error();
     if (!isset($userdata) && empty($userdata) && !is_array($userdata)) {
         $reg_errors->add('data_invalid', 'Chybí vstupní data');
         return $reg_errors;
     }
     $userLogin = array_key_exists('user_login', $userdata) ? sanitize_user($userdata['user_login']) : '';
     $userPass = array_key_exists('user_pass', $userdata) ? esc_attr($userdata['user_pass']) : '';
     $userEmail = array_key_exists('user_email', $userdata) ? sanitize_email($userdata['user_email']) : '';
     $userUrl = array_key_exists('user_url', $userdata) ? esc_url($userdata['user_url']) : '';
     $firstName = array_key_exists('first_name', $userdata) ? sanitize_text_field($userdata['first_name']) : '';
     $lastName = array_key_exists('last_name', $userdata) ? sanitize_text_field($userdata['last_name']) : '';
     $nickname = array_key_exists('nickname', $userdata) ? sanitize_text_field($userdata['nickname']) : '';
     $description = array_key_exists('description', $userdata) ? sanitize_text_field($userdata['description']) : '';
     if (empty($userLogin) || empty($userPass) || empty($userEmail)) {
         $reg_errors->add('field', 'Nejsou vyplnněny povinné pole formuláře.');
     }
     if (4 > strlen($userLogin)) {
         $reg_errors->add('username_length', 'Příliš krátké uživatelské jméno. Zadejte minimálně 5 znaků.');
     }
     if (username_exists($userLogin)) {
         $reg_errors->add('user_name', 'Je nám líto ale uživatelské jméno již existuje.');
     }
     if (!validate_username($userLogin)) {
         $reg_errors->add('username_invalid', 'Neplatné uživatelské jméno.');
     }
     if (5 > strlen($userPass)) {
         $reg_errors->add('password', 'Heslo musí obsahovat minimálně 6 znaků.');
     }
     if (!is_email($userEmail)) {
         $reg_errors->add('email_invalid', 'Zadaný e-mail je ve špatném formátu.');
     }
     if (email_exists($userEmail)) {
         $reg_errors->add('email', 'Zadaný e-mail již existuje.');
     }
     if (!empty($userUrl)) {
         if (!filter_var($userUrl, FILTER_VALIDATE_URL)) {
             $reg_errors->add('website', 'Url adresa Vašich stránek není validní.');
         }
     }
     if (is_wp_error($reg_errors) && count($reg_errors->errors) > 0) {
         return $reg_errors;
     }
     $_userdata = array('user_login' => $userLogin, 'user_email' => $userEmail, 'user_pass' => $userPass, 'user_url' => $userUrl, 'first_name' => $firstName, 'last_name' => $lastName, 'nickname' => $nickname, 'description' => $description, 'role' => 'customer');
     $user_id = wp_insert_user($_userdata);
     if (is_wp_error($user_id)) {
         $reg_errors->add('insert_user', 'Registraci nelze dokončit. Kontaktujte prosím správce webu.');
         return $reg_errors;
     }
     // Woocomerce data
     if (array_key_exists('billing_first_name', $userdata)) {
         add_user_meta($user_id, $meta_key, $meta_value, $unique);
     }
     $description = array_key_exists('description', $userdata) ? sanitize_text_field($userdata['description']) : '';
     return $user_id;
 }
Esempio n. 22
0
 /**
  * Process registration form submission
  *
  * @since 1.0
  */
 public function process_registration($data)
 {
     if (!isset($_POST['affwp_register_nonce']) || !wp_verify_nonce($_POST['affwp_register_nonce'], 'affwp-register-nonce')) {
         return;
     }
     do_action('affwp_pre_process_register_form');
     if (!is_user_logged_in()) {
         // Loop through required fields and show error message
         foreach ($this->required_fields() as $field_name => $value) {
             if (empty($_POST[$field_name])) {
                 $this->add_error($value['error_id'], $value['error_message']);
             }
         }
         if (username_exists($data['affwp_user_login'])) {
             $this->add_error('username_unavailable', __('Username already taken', 'affiliate-wp'));
         }
         if (!validate_username($data['affwp_user_login'])) {
             if (is_multisite()) {
                 $this->add_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'affiliate-wp'));
             } else {
                 $this->add_error('username_invalid', __('Invalid username', 'affiliate-wp'));
             }
         }
         if (email_exists($data['affwp_user_email'])) {
             $this->add_error('email_unavailable', __('Email address already taken', 'affiliate-wp'));
         }
         if (empty($data['affwp_user_email']) || !is_email($data['affwp_user_email'])) {
             $this->add_error('email_invalid', __('Invalid email', 'affiliate-wp'));
         }
         if (!empty($data['affwp_payment_email']) && $data['affwp_payment_email'] != $data['affwp_user_email'] && !is_email($data['affwp_payment_email'])) {
             $this->add_error('payment_email_invalid', __('Invalid payment email', 'affiliate-wp'));
         }
         if (!empty($_POST['affwp_user_pass']) && empty($_POST['affwp_user_pass2']) || $_POST['affwp_user_pass'] !== $_POST['affwp_user_pass2']) {
             $this->add_error('password_mismatch', __('Passwords do not match', 'affiliate-wp'));
         }
     }
     $terms_of_use = affiliate_wp()->settings->get('terms_of_use');
     if (!empty($terms_of_use) && empty($_POST['affwp_tos'])) {
         $this->add_error('empty_tos', __('Please agree to our terms of use', 'affiliate-wp'));
     }
     if (!empty($_POST['affwp_honeypot'])) {
         $this->add_error('spam', __('Nice try honey bear, don\'t touch our honey', 'affiliate-wp'));
     }
     if (affwp_is_affiliate()) {
         $this->add_error('already_registered', __('You are already registered as an affiliate', 'affiliate-wp'));
     }
     do_action('affwp_process_register_form');
     // only log the user in if there are no errors
     if (empty($this->errors)) {
         $this->register_user();
         $redirect = apply_filters('affwp_register_redirect', $data['affwp_redirect']);
         if ($redirect) {
             wp_redirect($redirect);
             exit;
         }
     }
 }
function getOrCreateAuthor($email, $name)
{
    $user_id = email_exists($email);
    if (!$user_id and email_exists($email) == false) {
        $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
        $user_id = wp_create_user($name, $random_password, $email);
    }
    return $user_id;
}
Esempio n. 24
0
 public function check_email()
 {
     $email = sanitize_text_field($_POST['email']);
     if (email_exists($email)) {
         echo 'false';
     } else {
         echo 'true';
     }
     die;
 }
 /**
  * Handles sending password retrieval email to user.
  *
  * @uses $wpdb WordPress Database object
  *
  * @return bool|WP_Error True: when finish. WP_Error on error
  */
 function retrieve_password()
 {
     global $wpdb, $current_site, $wpc_client;
     if (empty($_POST['user_login'])) {
         $data['error_msg'] = __('<strong>ERROR</strong>: Enter a username or e-mail address.', WPC_CLIENT_TEXT_DOMAIN);
         return $data['error_msg'];
     } else {
         if (strpos($_POST['user_login'], '@')) {
             if (!preg_match("/^([a-z0-9_\\.-]+)@([a-z0-9_\\.-]+)\\.([a-z\\.]{2,6})\$/", trim($_POST['user_login']))) {
                 $data['error_msg'] = __('<strong>ERROR</strong>: Invalid E-mail.', WPC_CLIENT_TEXT_DOMAIN);
                 return $data['error_msg'];
             } elseif (!email_exists(trim($_POST['user_login']))) {
                 $data['error_msg'] = __('<strong>ERROR</strong>: There is no user registered with that E-mail address.', WPC_CLIENT_TEXT_DOMAIN);
                 return $data['error_msg'];
             } else {
                 $user_data = get_user_by('email', trim($_POST['user_login']));
             }
         } else {
             $login = trim($_POST['user_login']);
             $user_data = get_user_by('login', $login);
             if (empty($user_data)) {
                 $data['error_msg'] = __('<strong>ERROR</strong>: There is no user registered with that Username.', WPC_CLIENT_TEXT_DOMAIN);
                 return $data['error_msg'];
             }
         }
     }
     //check permission for reset password
     if (!user_can($user_data, 'wpc_reset_password')) {
         $data['error_msg'] = __('<strong>ERROR</strong>:  You do not have permission to reset your password.', WPC_CLIENT_TEXT_DOMAIN);
         return $data['error_msg'];
     }
     // redefining user_login ensures we return the right case in the email
     $user_login = $user_data->user_login;
     $user_email = $user_data->user_email;
     $key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM {$wpdb->users} WHERE user_login = %s", $user_login));
     if (empty($key)) {
         // Generate something random for a key...
         $key = wp_generate_password(20, false);
         // Now insert the new md5 key into the db
         $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
     }
     /*if ( is_multisite() )
           $blogname = $GLOBALS['current_site']->site_name;
       else
           // The blogname option is escaped with esc_html on the way into the database in sanitize_option
           // we want to reverse this for the plain text arena of emails.
           $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );  */
     //$title = sprintf( __('[%s] Password Reset'), $blogname );
     $args = array('client_id' => $user_data->ID, 'reset_address' => htmlspecialchars(add_query_arg(array('action' => 'rp', 'key' => $key, 'login' => rawurlencode($user_login)), $wpc_client->cc_get_login_url())));
     //send email
     if (!$wpc_client->cc_mail('reset_password', $user_email, $args, 'reset_password')) {
         wp_die(__('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...'));
     }
     return true;
 }
Esempio n. 26
0
 function __construct()
 {
     global $wpdb;
     if (isset($_POST['crg_login_email'])) {
         $crg_login_email = $_POST['crg_login_email'];
     }
     //the user has entered an email address, but no password is entered:
     if (isset($_POST['crg_login_email']) && !isset($_POST['crg_login_password'])) {
         if (email_exists($crg_login_email)) {
             //The user has entered an existing email
             $login_link = wp_login_url(get_permalink());
             $url = getUrl($_SERVER);
             $_SESSION['crg_login_email'] = $_POST['crg_login_email'];
             if (!isset($_SESSION['crg_login_redirect_url'])) {
                 $_SESSION['crg_login_redirect_url'] = $_SERVER['HTTP_REFERER'];
             }
             wp_redirect($login_link);
             die;
             //the user has entered an email address, that is NOT in the database:
         } else {
             $password = wp_generate_password();
             $user_id = wp_create_user($crg_login_email, $password, $crg_login_email);
             $user = new WP_User($user_id);
             wp_set_auth_cookie($user->ID, TRUE);
             //either 'administrator', 'subscriber', 'editor', 'author', 'contributor':
             $user->set_role('subscriber');
             $first_name = $_POST['crg_login_first_name'];
             $last_name = $_POST['crg_login_last_name'];
             $user_id = wp_update_user(array('ID' => $user_id, 'first_name' => $first_name, 'last_name' => $last_name));
             $creds = array();
             $creds['user_login'] = $crg_login_email;
             $creds['user_password'] = $password;
             $creds['remember'] = true;
             $user = wp_signon($creds, true);
             $user = get_user_by('email', $crg_login_email);
             $x = $user->ID;
             $xyz = crg_trim_email($crg_login_email);
             update_user_meta($x, 'nickname', $xyz);
             $wpdb->query("UPDATE {$wpdb->users} SET display_name = '{$xyz}' WHERE ID = {$x}");
             if (isset($_SESSION['crg_login_redirect_url'])) {
                 $crg_login_redirect_url = $_SESSION['crg_login_redirect_url'];
                 wp_redirect($crg_login_redirect_url);
                 die;
             }
             //gets the current url:
             $url = getUrl($_SERVER);
             wp_redirect($url);
             die;
         }
     }
     //error condition:
     if (isset($_POST['crg_login_email']) && isset($_POST['crg_login_password'])) {
         die("ERROR:both here");
     }
 }
 function uultra_handle_errors()
 {
     global $xoouserultra;
     //check if retype-password
     $password_retype = $xoouserultra->get_option("set_password_retype");
     if (get_option('users_can_register') == '1') {
         foreach ($this->usermeta as $key => $value) {
             /* Validate username */
             if ($key == 'user_login') {
                 if (esc_attr($value) == '') {
                     $this->errors[] = __('<strong>ERROR:</strong> Please enter a username.', 'xoousers');
                 } elseif (username_exists($value)) {
                     $this->errors[] = __('<strong>ERROR:</strong> This username is already registered. Please choose another one.', 'xoousers');
                 }
             }
             /* Validate email */
             if ($key == 'user_email') {
                 if (esc_attr($value) == '') {
                     $this->errors[] = __('<strong>ERROR:</strong> Please type your e-mail address.', 'xoousers');
                 } elseif (!is_email($value)) {
                     $this->errors[] = __('<strong>ERROR:</strong> The email address isn\'t correct.', 'xoousers');
                 } elseif ($value != $_POST['user_email_2']) {
                     if ($password_retype != 'no') {
                         $this->errors[] = __('<strong>ERROR:</strong> The emails are different.', 'xoousers');
                     }
                 } elseif (email_exists($value)) {
                     $this->errors[] = __('<strong>ERROR:</strong> This email is already registered, please choose another one.', 'xoousers');
                 }
             }
         }
         //check if auto-password
         $auto_password = $xoouserultra->get_option("set_password");
         //check if retype-password
         $password_retype = $xoouserultra->get_option("set_password_retype");
         if ($auto_password == '' || $auto_password == 1) {
             /* Validate passowrd */
             if ($_POST["user_pass"] == "") {
                 $this->errors[] = __('<strong>ERROR:</strong> Please type your password.', 'xoousers');
             }
             if ($_POST["user_pass"] != $_POST["user_pass_confirm"]) {
                 $this->errors[] = __('<strong>ERROR:</strong> The passwords must be identical', 'xoousers');
             }
             //password strenght
             $this->uultra_check_pass_strenght($_POST["user_pass"]);
         }
         if (!is_in_post('no_captcha', 'yes')) {
             if (!$xoouserultra->captchamodule->validate_captcha(post_value('captcha_plugin'))) {
                 $this->errors[] = __('<strong>ERROR:</strong> Please complete Captcha Test first.', 'xoousers');
             }
         }
     } else {
         $this->errors[] = __('<strong>ERROR:</strong> Registration is disabled for this site.', 'xoousers');
     }
 }
Esempio n. 28
0
function acui_hack_email($email)
{
    if (!is_email($email)) {
        return;
    }
    $old_email = $email;
    for ($i = 0; !$skip_remap && email_exists($email); $i++) {
        $email = str_replace('@', "+ama{$i}@", $old_email);
    }
    return $email;
}
Esempio n. 29
0
 function get_fb($code)
 {
     if (!$code) {
         not_found();
     }
     $url = "https://graph.facebook.com/oauth/access_token?" . 'client_id=' . FACEBOOK_APP_ID . '&redirect_uri=http://' . $_SERVER['HTTP_HOST'] . '/api/fb' . '&client_secret=' . FACEBOOK_APP_KEY . '&code=' . urlencode($code);
     // var_dump($_SERVER)
     // print $url;
     $ret = http_get($url);
     if (isset($ret['error']) || !isset($ret['access_token'])) {
         server_error($ret['error']['message']);
     }
     $at = $ret['access_token'];
     $sig = _gen_sig($at);
     $url = "https://graph.facebook.com/me?access_token=" . $at;
     $dat = http_get($url);
     if (!isset($dat['id'])) {
         return server_error('invalid record');
     }
     $user_id = email_exists($dat['email']);
     if (!is_file(get_stylesheet_directory() . '/sdk/cache/' . $dat['id'] . '.jpg')) {
         file_put_contents(get_stylesheet_directory() . '/sdk/cache/' . $dat['id'] . '.jpg', file_get_contents(get_bloginfo('template_directory') . '/sdk/timthumb.php?src=http://graph.facebook.com/' . $dat['id'] . '/picture?type=large&w=75&h=75'));
     }
     if ($user_id) {
         // Existing user.
         $user_data = get_userdata($user_id);
         $user_login = $user_data->user_login;
         // @TODO do a check against user meta to make sure its the same user
     } else {
         // New user.
         if (!isset($dat['username'])) {
             $dat['username'] = $dat['first_name'] . '_' . $dat['last_name'];
         }
         $userdata = array('user_login' => $dat['username'], 'user_email' => $dat['email'], 'first_name' => $dat['first_name'], 'last_name' => $dat['last_name'], 'user_url' => $dat['link'], 'user_pass' => wp_generate_password());
         $user_id = wp_insert_user($userdata);
         if (is_wp_error($user)) {
             return server_error('Something went wrong with creating your user.');
         }
         // switch off the wordpress bar, which is on by default
         update_user_meta($user_id, 'show_admin_bar_front', false);
         if (is_file(get_stylesheet_directory() . '/sdk/cache/' . $dat['id'] . '.jpg')) {
             update_user_meta($user_id, 'hg_profile_url', get_stylesheet_directory_uri() . '/sdk/cache/' . $dat['id'] . '.jpg');
         }
     }
     // log the user in..
     wp_set_auth_cookie($user_id, true);
     // store login details
     update_user_meta($user_id, 'hg_facebook', true);
     update_user_meta($user_id, 'hg_facebook_id', $dat['id']);
     update_user_meta($user_id, 'hg_facebook_acess_token', $at);
     update_user_meta($user_id, 'hg_facebook_sig', $sig);
     $json_user_info = json_encode(array('username' => $dat['username'], 'email' => $dat['email'], 'access_token' => $at, 'sig' => $sig));
     require_once 'templates/oauth_popup_close.php';
 }
function create_microweb()
{
    global $_POST, $current_site, $current_user;
    if (!is_array($_POST['blog'])) {
        wp_die(__('Can&#8217;t create an empty site.'));
    }
    $blog = $_POST['blog'];
    $email = sanitize_email($blog['email']);
    $title = $blog['title'];
    $domain = $blog['domain'];
    if (empty($domain)) {
        print_r(__('Missing or invalid site address.'));
    }
    if (empty($email)) {
        print_r(__('Missing email address.'));
    }
    if (!is_email($email)) {
        print_r(__('Invalid email address.'));
    }
    if (is_subdomain_install()) {
        $newdomain = $domain . '.' . preg_replace('|^www\\.|', '', $current_site->domain);
        $path = $current_site->path;
    } else {
        $newdomain = $current_site->domain;
        $path = $current_site->path . $domain . '/';
    }
    $password = '******';
    $user_id = email_exists($email);
    if ($user_id) {
        $password = wp_generate_password(12, false);
        $user_id = wp_update_user(array("ID" => $user_id, "user_pass" => $password));
        if (false == $user_id) {
            print_r(__('There was an error updating the user.'));
        } else {
            wp_new_user_notification($user_id, $password);
        }
    }
    $id = wpmu_create_blog($newdomain, $path, $title, $user_id, array('public' => 1), $current_site->id);
    if (!is_wp_error($id)) {
        update_user_meta($user_id, "agent-web", $path);
        if (!is_super_admin($user_id) && !get_user_option('primary_blog', $user_id)) {
            update_user_option($user_id, 'primary_blog', $id, true);
        }
        $content_mail = sprintf(__('New site created by %1$s

Address: %2$s
Name: %3$s'), $current_user->user_login, get_site_url($id), stripslashes($title));
        wp_mail(get_site_option('admin_email'), sprintf(__('[%s] New Site Created'), $current_site->site_name), $content_mail, 'From: "Site Admin" <' . get_site_option('admin_email') . '>');
        wpmu_welcome_notification($id, $user_id, $password, $title, array('public' => 1));
        // wp_redirect( add_query_arg( array( 'update' => 'added', 'id' => $id ), 'site-new.php' ) );
        // exit;
    } else {
        wp_die($id->get_error_message());
    }
}