示例#1
0
 /**
  * Update user status when denying user.
  *
  * @uses new_user_approve_deny_user
  */
 public function update_deny_status($user_id)
 {
     $user = new WP_User($user_id);
     // Get dream city camp info.
     $camp = DreamCityCamp::withUserId($user_id);
     if ($camp != false) {
         $current_user = wp_get_current_user();
         // if "append" is set to true, the function does not add note!
         dc_camp_update_notes($camp->camp_id, date("Y-m-d H:i:s") . " - denied by " . $current_user->display_name, true);
     }
     // change usermeta tag in database to denied
     update_user_meta($user->ID, 'pw_user_status', 'denied');
     do_action('new_user_approve_user_denied', $user);
 }
示例#2
0
文件: form.php 项目: 0dp/dreamcity
function dc_process_reg_form()
{
    global $dc_form_success;
    $Ok = true;
    $dc_form_success = "";
    if (isset($_POST["dc_user_email"]) && isset($_POST["dc_register_nonce"]) && wp_verify_nonce($_POST['dc_register_nonce'], 'dc-register-nonce')) {
        $camp_workshop1 = "";
        $camp_workshop2 = "";
        $camp_workshop3 = "";
        $camp_workshop4 = "";
        $user_login = $_POST["dc_user_email"];
        $user_email = $_POST["dc_user_email"];
        $user_first = $_POST["dc_user_first"];
        $user_last = $_POST["dc_user_last"];
        $camp_phone = $_POST["dc_user_phone"];
        $camp_name = $_POST["dc_user_camp_name"];
        $camp_pat_no = $_POST["dc_user_participants"];
        $camp_pro_desc = $_POST["dc_user_project_desc_one"] . "\r\n\r\n" . $_POST["dc_user_project_desc_two"] . "\r\n\r\n" . $_POST["dc_user_project_desc_three"] . "\r\n\r\n" . $_POST["dc_user_project_desc_four"];
        $camp_pro_cons = $_POST["dc_user_project_construction"];
        $camp_short_desc = $_POST['dc_user_short_desc'];
        if (isset($_POST["dc_optionsRadios1"])) {
            $camp_workshop1 = $_POST["dc_optionsRadios1"];
        }
        if (isset($_POST["dc_optionsRadios2"])) {
            $camp_workshop2 = $_POST["dc_optionsRadios2"];
        }
        if (isset($_POST["dc_optionsRadios3"])) {
            $camp_workshop3 = $_POST["dc_optionsRadios3"];
        }
        if (isset($_POST["dc_optionsRadios4"])) {
            $camp_workshop4 = $_POST["dc_optionsRadios4"];
        }
        $camp = DreamCityCamp::withDetails($user_login, $user_first, $user_last, $user_email, $camp_phone, $camp_name, $camp_pro_desc, $camp_pro_cons, $camp_pat_no, $camp_short_desc, $camp_workshop1, $camp_workshop2, $camp_workshop3, $camp_workshop4);
        $email_inuse = email_exists($camp->user_email);
        $user_status = 'approved';
        if ($email_inuse) {
            $user_status = get_user_meta($email_inuse, 'pw_user_status', true);
        }
        if (empty($user_status)) {
            $user_status = 'approved';
        }
        if ($camp->HasError()) {
            $dc_form_success = "error";
            $Ok = false;
        } else {
            if ($email_inuse && $user_status == 'denied') {
                $camp->user_id = $email_inuse;
                $camp_old_data = DreamCityCamp::withUserId($camp->user_id);
                $camp->camp_id = $camp_old_data->camp_id;
                $camp->camp_notes = $camp_old_data->camp_notes;
                if (!$camp->UpdateCampOnUserId()) {
                    $dc_form_success = "error";
                    $Ok = false;
                } else {
                    dc_camp_update_notes($camp->camp_id, date("Y-m-d H:i:s") . " - Camp reapplied", true);
                    update_user_meta($camp->user_id, 'pw_user_status', 'pending');
                }
            } else {
                if (!$camp->AddCampToDatabase()) {
                    // This will reject if user already exist! as this will try to create new camp.
                    // Show an error?
                    $dc_form_success = "error";
                    $Ok = false;
                }
            }
            //wp_new_user_notification($camp->user_id,'', 'both');
            // log the new user in
            //wp_setcookie($user_login, $user_pass, true);
            //wp_set_current_user($new_user_id, $user_login);
            //do_action('wp_login', $user_login);
            // send the newly created user to the home page after logging them in and add a confirmation message
            if ($Ok) {
                $to = $camp->user_email;
                $message = sprintf("Hey %s. \r\nWe have received your registration. Once we have reviewed it we will get back to you. \r\r\n\n Dream On", $camp->camp_name, ENT_QUOTES);
                $subject = "Welcome to Dream City";
                // $att = create_pdf($camp);
                // //$att = chunk_split(base64_encode($pdfdoc));
                // $separador = md5(time());
                // $headers  = "From: no-reply@dream-city.dk\r\n";
                // $headers .= "MIME-Version: 1.0"."\r\n";
                // $headers .= "Content-Type: multipart/mixed; boundary=\"".$separador."\"";
                // $headers .= "Content-Transfer-Encoding: 8bit"."\r\n";
                // $headers .= "This is a MIME encoded message."."\r\n";
                // $headers .= "Content-Type: application/octet-stream name=\""."application.pdf"."\"";
                // $headers .= "Content-Transfer-Encoding: base64";
                // $headers .= "Content-Disposition: attachment; filename=\""."application.pdf"."\"";
                //include $att
                wp_mail($to, $subject, $message, '');
                //$Ok = true;
                $dc_form_success = "success";
                //return $dc_registration_form_fields;
                wp_redirect('http://dream-city.dk/become-a-dreamer/registration' . '?state=success', 200);
                exit;
                //wp_redirect('http://localhost/wordpress/become-a-dreamer/registration' . '?state=success', 200); exit;
            }
        }
    }
}