1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | <form id= "registration_form" action= "" method= "post" enctype= "multipart/form-data" > <div class = "input_field_wrap" > <label><span>*</span>indicates required</label> </div><!--input_field_wrap--> <div id= "hp" class = "input_field_wrap" > <label>Honey Pot (If you can see this, leave this blank</label> <input type= "text" name= "hp" value= "" size= "20" placeholder= "Big Name" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "first_name_wrap" > <label><span>*</span>First Name</label> <input type= "text" name= "first_name" id= "first_name" value= "<? echo $_POST['first_name']; ?>" size= "20" placeholder= "First Name" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "last_name_wrap" > <label><span>*</span>Last Name</label> <input type= "text" name= "last_name" id= "last_name" value= "<? echo $_POST['last_name']; ?>" size= "20" placeholder= "Last Name" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "email_address_wrap" > <label><span>*</span>Email Address</label> <input type= "text" name= "email_address" id= "email_address" value= "<? echo $_POST['email_address']; ?>" size= "20" placeholder= "Email Address" class = "text_input" /><span id= "re_email" ></span> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "account_password_wrap" > <label><span>*</span>Account Password</label> <input type= "password" name= "account_password" id= "account_password" value= "" size= "20" placeholder= "account password" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "confirm_password_wrap" > <label><span>*</span>Confirm Password</label> <input type= "password" name= "confirm_password" id= "confirm_password" value= "" size= "20" placeholder= "confirm password" class = "text_input" /> </div><!--input_field_wrap--> <div id= "human_error" > <label><span> *</span>Human Test</label> <div class = "input_field_wrap" id= "h_test_wrap" > <input type= "text" name= "h_test" id= "h_test" value= "<? echo $_POST['h_test']; ?>" size= "20" placeholder= "" class = "text_input" /> </div><!--input_field_wrap--></div> <? wp_nonce_field( 'process_custom_registration_form' , 'custom_registration_nonce' ); ?> <div class = "input_field_wrap" > <button type= "submit" id= "reg_submit" class = "submit text_input" >Submit > </button> </div><!--input_field_wrap--> <div id= "errors_wrap" class = "input_field_wrap" > <label><span> *</span>Errors</label> <? if (! empty ( $all_errors )) { foreach ( $all_errors as $error ) { ?> <? echo $error [ 'message' ]. "<br />" ; ?> <? } } ?> </div><!--input_field_wrap--> <input type= "hidden" name= "registration_form_submitted" value= "true" /> </form> |
1 2 3 4 5 6 7 8 9 10 | function check_added_registration_fields( $errors , $sanitized_user_login , $user_email ) { if (!wp_verify_nonce( $_POST [ 'custom_registration_nonce' ], 'process_custom_registration_form' )) { $errors ->add( 'agree_error' , __( '<strong>ERROR</strong>: Not From Around Here Are You!' , 'mydomain' ) ); } return $errors ; } add_filter( 'registration_errors' , 'check_added_registration_fields' , 10, 3); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | function custom_registration_submission() { //657AM global $all_errors ; if (isset( $_POST [ 'registration_form_submitted' ])) { // 333PM THIS CATCHES FORM SUBMISSIONS if (!wp_verify_nonce( $_POST [ 'custom_registration_nonce' ], 'process_custom_registration_form' )) { exit ; } if (! empty ( $_POST [ 'hp' ])) { echo "no empty hp" ; exit ; } if ( $_POST [ 'h_test' ] != 5 ) { $reg_errors [ 'tag' ] = "#human_error" ; $reg_errors [ 'message' ] = "Check Human Test" ; $all_errors [] = $reg_errors ; $has_errors = true; } $first_name = $_POST [ 'first_name' ]; $last_name = $_POST [ 'last_name' ]; $email_address = $_POST [ 'email_address' ]; $account_password = $_POST [ 'account_password' ]; $confirm_password = $_POST [ 'confirm_password' ]; $has_errors = false; if ( empty ( $first_name )) { $reg_errors [ 'tag' ] = "#first_name_wrap" ; $reg_errors [ 'message' ] = "Forgot First Name" ; $all_errors [] = $reg_errors ; $has_errors = true; } if ( empty ( $last_name )) { $reg_errors [ 'tag' ] = "#last_name_wrap" ; $reg_errors [ 'message' ] = "Forgot Last Name" ; $all_errors [] = $reg_errors ; $has_errors = true; } if ( empty ( $email_address )) { // 1000AM $reg_errors [ 'tag' ] = "#email_address_wrap" ; $reg_errors [ 'message' ] = "Forgot Email" ; $all_errors [] = $reg_errors ; $has_errors = true; } else { // 1000AM if (!filter_var( $email_address , FILTER_VALIDATE_EMAIL)) { $reg_errors [ 'tag' ] = "#email_address_wrap" ; $reg_errors [ 'message' ] = "Invalid Email" ; $all_errors [] = $reg_errors ; $has_errors = true; } if ( email_exists( $email_address )) { $reg_errors [ 'tag' ] = "#email_address_wrap" ; $reg_errors [ 'message' ] = "Email Unavailable" ; $all_errors [] = $reg_errors ; $has_errors = true; } } // 1000AM if ( empty ( $account_password )) { //1044AM $reg_errors [ 'tag' ] = "#account_password_wrap" ; $reg_errors [ 'message' ] = "Forgot Password" ; $all_errors [] = $reg_errors ; $has_errors = true; } else { //1044AM if ( strlen ( $account_password ) < 7 ) { $reg_errors [ 'tag' ] = "#account_password_wrap" ; $reg_errors [ 'message' ] = "Password must be 7 characters or more" ; $all_errors [] = $reg_errors ; $has_errors = true; } } //1044AM if ( empty ( $confirm_password )) { //1044AM $reg_errors [ 'tag' ] = "#confirm_password_wrap" ; $reg_errors [ 'message' ] = "Confirm Password" ; $all_errors [] = $reg_errors ; $has_errors = true; } else { //1044AM if ( $confirm_password != $account_password ) { $reg_errors [ 'tag' ] = "#confirm_password_wrap" ; $reg_errors [ 'message' ] = "Passwords must match" ; $all_errors [] = $reg_errors ; $has_errors = true; } } //1044AM if ( $has_errors == false ) { //605AM $user_id = wp_insert_user( array ( 'user_login' => $email_address , 'user_pass' => $confirm_password , 'first_name' => $first_name , 'last_name' => $last_name , 'user_email' => $email_address , 'display_name' => $first_name . ' ' . $last_name , 'nickname' => $first_name . ' ' . $last_name , 'role' => 'None' ) ); //wp_new_user_notification( $user_id, $confirm_password ); ////////////////////////////// WELCOME EMAIL ///////////////////////////////////// $random_num_1 =mt_rand(100000000,999999999); strval ( $random_num_1 ); $random_num_2 =mt_rand(100000000,999999999); strval ( $random_num_2 ); $random_num_3 =mt_rand(100000000,999999999); strval ( $random_num_3 ); $random_id = $random_num_2 . $random_num_2 . $random_num_3 ; $email_verifications = get_option( 'email_verifications' ); $reginfo [ 'random_id' ] = $random_id ; $reginfo [ 'user_id' ] = $user_id ; $email_verifications [] = $reginfo ; update_option( 'email_verifications' , $email_verifications ); $headers [] = 'From: somewhere.com < info@gsomewhere.com>' ; $headers [] = 'content-type: text/html' ; $title = "somewhere.com - WELCOME" ; $styled_email_to_mail = "Thank you for registering with somewhere.com.<br />" ; $styled_email_to_mail .= "To confirm this email address please click the link below.<br /><br />" ; $styled_email_to_mail .= "<a href='http://somewhere.com/email-verification?activate=$random_id'>http://somewhere.com/email-verification?activate=$random_id<a><br /><br />" ; $styled_email_to_mail .= "Once you have confirmed your email address please use the info below to access your profile.<br /><br />" ; $styled_email_to_mail .= "<a href='http://somewhere.com/wp-admin'>http://gsomewhere.com/wp-admin<a><br /><br />" ; $styled_email_to_mail .= "<br /><br />username: $email_address <br />password: $confirm_password" ; wp_mail( $email_address , $title , $styled_email_to_mail , $headers ); ////////////////////////////// WELCOME EMAIL ///////////////////////////////////// } else { return ; } //605AM exit ; } // 333PM } //657AM add_action( 'wp_loaded' , 'custom_registration_submission' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function my_login_redirect( $redirect_to , $request , $user ) { //is there a user to check? global $user ; if ( isset( $user ->roles ) && is_array ( $user ->roles ) ) { //check for admins if ( in_array( 'administrator' , $user ->roles ) ) { // redirect them to the default place return $redirect_to ; } else { } } else { return $redirect_to ; } } add_filter( 'login_redirect' , 'my_login_redirect' , 10, 3 ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <? add_action( 'show_user_profile' , 'extra_user_profile_fields' ); add_action( 'edit_user_profile' , 'extra_user_profile_fields' ); add_action( 'personal_options_update' , 'save_extra_user_profile_fields' ); add_action( 'edit_user_profile_update' , 'save_extra_user_profile_fields' ); function save_extra_user_profile_fields( $user_id ) { ?> <script> jQuery( document ).ready( function () { jQuery( '#your-profile' ).attr( 'enctype' , 'multipart/form-data' ); } ); </script> <? include get_template_directory(). '/admin/save_added_meta.php' ; ////////////////////////////////////// SAVE HERE //////////////// } function extra_user_profile_fields( $user ) { // 941AM $added_meta = get_the_author_meta( 'added_meta' , $user ->ID ); $email_status = $added_meta [ 'email_status' ]; ?> <h3>Extra User Profile Fields</h3> <h3>User ID <? echo $user ->ID; ?></h3> <div class = "input_field_wrap" > <label>Email Status</label> <input type= "text" name= "email_status" value= "<? echo $email_status; ?>" size= "20" placeholder= "" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "profile_pic_wrap" > <label>Profile Picture</label> <input type= "file" name= "profile_pic" id= "profile_pic" /></div> <? if (! empty ( $profile_pic [ 'small_size' ])) { ?> <div class = "pic_wrap" > <img class = "profile_pic" src= "<? echo $profile_pic['small_size']; ?>" /> <div class = "checkbox_field_wrap delete_pic" > <input type= "checkbox" value= "true" name= "delete_profile_pic" /> Delete profile pic 1</div> </div><!--pic wrap--> <? } ?> <div class = "input_field_wrap" id= "bio_wrap" > <label>Profile Bio</label> <textarea name= "bio" id= "bio" ></textarea> </div><!--input_field_wrap--> <? } // 941AM ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | <? $user_ID = get_current_user_id(); get_the_author_meta( $field , $userID ); global $status ; $first_name = get_the_author_meta( 'user_firstname' , $user_ID ); $last_name = get_the_author_meta( 'user_lastname' , $user_ID ); $user_email = get_the_author_meta( 'user_email' , $user_ID ); $added_meta = get_the_author_meta( 'added_meta' , $user_ID ); ?> <style> .input_field_wrap { margin-bottom: 15px; } label { display: inline-block; width: 195px; font-size: inherit; } #h_test_wrap { padding-left: 60px; background-repeat: no-repeat; background-position: 5px 5px; } #h_test { width: 15px; } #human_error label { margin-bottom: 5px; display: inline-block; } #errors_wrap { display: none; } #errors_wrap label { display: block; } #reg_submit { background: none; border: none; cursor: pointer; font-size: inherit; } <? global $all_errors , $all_updates ; ?> <? if (! empty ( $all_errors )) { foreach ( $all_errors as $error ) { ?> <? echo $error [ 'tag' ]; ?> input { border: 1px solid red; } <? } ?> #errors_wrap { display: block; color: red; } <? } ?> <? if (! empty ( $all_errors )) { foreach ( $all_errors as $error ) { ?> <? echo $error [ 'tag' ]; ?> input { border: 1px solid red; } <? } ?> #errors_wrap { display: block; color: red; } <? } ?> <? if (! empty ( $all_updates )) { foreach ( $all_updates as $update ) { ?> <? echo $update [ 'tag' ]; ?> input { border: 1px solid green; } <? } ?> #updates_wrap { display: block; color: green; } <? } ?> </style> <form id= "pilot_profile_form" action= "" method= "post" enctype= "multipart/form-data" > <div class = "input_field_wrap" > <label><span>*</span>indicates required</label> </div><!--input_field_wrap--> <div id= "hp" class = "input_field_wrap" > <label>Honey Pot (If you can see this, leave this blank</label> <input type= "text" name= "hp" value= "" size= "20" placeholder= "Big Name" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "first_name_wrap" > <label><span>*</span>First Name</label> <input type= "text" name= "first_name" id= "first_name" value= "<? echo $first_name; ?>" size= "20" placeholder= "First Name" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "last_name_wrap" > <label><span>*</span>Last Name</label> <input type= "text" name= "last_name" id= "last_name" value= "<? echo $last_name; ?>" size= "20" placeholder= "Last Name" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "email_address_wrap" > <label><span>*</span>Email Address</label> <input type= "text" name= "email_address" id= "email_address" value= "<? echo $user_email; ?>" size= "20" placeholder= "Email Address" class = "text_input" /><span id= "re_email" ></span> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "account_password_wrap" > <label><span>*</span>Account Password</label> <input type= "password" name= "account_password" id= "account_password" value= "" size= "20" placeholder= "account password" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "confirm_password_wrap" > <label><span>*</span>Confirm Password</label> <input type= "password" name= "confirm_password" id= "confirm_password" value= "" size= "20" placeholder= "confirm password" class = "text_input" /> </div><!--input_field_wrap--> <div class = "input_field_wrap" id= "profile_pic_wrap" > <label>Profile Picture</label> <input type= "file" name= "profile_pic" id= "profile_pic" /></div> <? if (! empty ( $profile_pic [ 'small_size' ])) { ?> <div class = "pic_wrap" > <img class = "profile_pic" src= "<? echo $profile_pic['small_size']; ?>" /> <div class = "checkbox_field_wrap delete_pic" > <input type= "checkbox" value= "true" name= "delete_profile_pic" /> Delete profile pic 1</div> </div><!--pic wrap--> <? } ?> <div class = "input_field_wrap" id= "bio_wrap" > <label>Profile Bio</label> <textarea name= "bio" id= "bio" ></textarea> </div><!--input_field_wrap--> <? wp_nonce_field( 'process_pilot_profile_form' , 'pilot_profile_nonce' ); ?> <div class = "input_field_wrap" > <button type= "submit" id= "reg_submit" class = "submit text_input" >Submit > </button> </div><!--input_field_wrap--> <div id= "errors_wrap" class = "input_field_wrap" > <label><span> *</span>Errors</label> <? if (! empty ( $all_errors )) { foreach ( $all_errors as $error ) { ?> <? echo $error [ 'message' ]. "<br />" ; ?> <? } } ?> </div><!--input_field_wrap--> <div id= "updates_wrap" class = "input_field_wrap" > <? if (! empty ( $all_updates )) { foreach ( $all_updates as $update ) { ?> <? echo $update [ 'message' ]. "<br />" ; ?> <? } } ?> </div><!--input_field_wrap--> <input type= "hidden" name= "pilot_profile_form_submitted" value= "true" /> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | function pilot_profile_form_submission() { //657AM global $all_errors , $all_updates , $wpdb ; if (isset( $_POST [ 'pilot_profile_form_submitted' ])) { // 333PM THIS CATCHES FORM SUBMISSIONS if (!wp_verify_nonce( $_POST [ 'pilot_profile_nonce' ], 'process_pilot_profile_form' )) { exit ; } if (! empty ( $_POST [ 'hp' ])) { echo "no empty hp" ; exit ; } $user_ID = get_current_user_id(); $first_name = $_POST [ 'first_name' ]; $last_name = $_POST [ 'last_name' ]; $user_name = $_POST [ 'user_name' ]; $email_address = $_POST [ 'email_address' ]; $account_password = $_POST [ 'account_password' ]; $confirm_password = $_POST [ 'confirm_password' ]; $original_user_login = get_the_author_meta( 'user_login' , $user_ID ); $original_first_name = get_the_author_meta( 'user_firstname' , $user_ID ); $original_last_name = get_the_author_meta( 'user_lastname' , $user_ID ); $original_user_email = get_the_author_meta( 'user_email' , $user_ID ); if ( $original_first_name != $first_name ) { wp_update_user( array ( 'ID' => $user_ID , 'first_name' => $first_name )); } if ( $original_last_name != $last_name ) { wp_update_user( array ( 'ID' => $user_ID , 'last_name' => $last_name )); } if ( $original_user_email != $email_address ) { //305PM $email_errors = false; if (filter_var( $email_address , FILTER_VALIDATE_EMAIL)) { //830PM if ( email_exists( $email_address )) { $reg_errors [ 'tag' ] = "#email_address_wrap" ; $reg_errors [ 'message' ] = "Email Unavailable" ; $all_errors [] = $reg_errors ; $email_errors = true; } else { } } else { $reg_errors [ 'tag' ] = "#email_address_wrap" ; $reg_errors [ 'message' ] = "Invalid Email" ; $all_errors [] = $reg_errors ; $email_errors = true; } //830PM if ( $email_errors == false) { // 214PM wp_update_user( array ( 'ID' => $user_ID , 'user_email' => $email_address )); $reg_updates [ 'tag' ] = "" ; $reg_updates [ 'message' ] = "Email Updated" ; $all_updates [] = $reg_updates ; $q = $wpdb ->prepare( "UPDATE $wpdb->users SET user_login = %s WHERE user_login = %s" , $email_address , $original_user_login ); $wpdb ->query( $q ); $redirect_login = true; } // 214PM } //305PM if ( ! empty ( $account_password ) && empty ( $confirm_password ) ) { $reg_errors [ 'tag' ] = "#account_password_wrap" ; $reg_errors [ 'message' ] = "Please Confirm Password" ; $all_errors [] = $reg_errors ; $pass_errors = true; } if ( ! empty ( $account_password ) && ! empty ( $confirm_password ) ) { //421PM if ( $account_password != $confirm_password ) { $reg_errors [ 'tag' ] = "#confirm_password_wrap" ; $reg_errors [ 'message' ] = "Password don't match" ; $all_errors [] = $reg_errors ; $pass_errors = true; } if ( $pass_errors != true ) { wp_update_user( array ( 'ID' => $user_ID , 'user_pass' => $account_password )); $reg_updates [ 'tag' ] = "" ; $reg_updates [ 'message' ] = "Password Updated" ; $all_updates [] = $reg_updates ; } } //421PM $profile_pic = $_FILES [ 'profile_pic' ]; if (! empty ( $_FILES [ 'profile_pic' ][ 'name' ])) { $added_meta [ 'profile_pic' ] = pic_handeler( $profile_pic , $user_ID ); } if ( $_POST [ 'delete_profile_pic' ] == true) { $added_meta [ 'profile_pic' ] = "" ; } // If email was changed they will have to log back in if ( $redirect_login == true) { wp_redirect( 'http://greatforestparkballoonrace.com/edit-pilot-profile/' ); } } // 333PM } //657AM add_action( 'wp_loaded' , 'pilot_profile_form_submission' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// function pic_handeler( $uploaded_file , $members_ID ) { // 629AM $root_folder = dirname( __FILE__ ) . "/member_images" ; if ( is_dir ( $root_folder ) === false){ mkdir ( $root_folder , 0777); } $image_folder = dirname( __FILE__ ) . "/member_images/$members_ID" ; if ( is_dir ( $image_folder ) === false){ mkdir ( $image_folder , 0777); } $allowed = array ( 'image/gif' , 'image/jpeg' , 'image/jpg' , 'image/pjpeg' , 'image/png' ); if (in_array( $uploaded_file [ 'type' ], $allowed )) { $storeduploadedfile = $uploaded_file [ 'tmp_name' ]; switch ( $uploaded_file [ 'type' ]) { case "image/jpg" : $this_file_type = ".jpg" ; $src = imagecreatefromjpeg( $storeduploadedfile ); break ; case "image/gift" : $this_file_type = ".gif" ; $src = imagecreatefromgif( $storeduploadedfile ); break ; case "image/jpeg" : $this_file_type = ".jpeg" ; $src = imagecreatefromjpeg( $storeduploadedfile ); break ; case "image/pjpeg" : $this_file_type = ".pjpeg" ; $src = imagecreatefromjpeg( $storeduploadedfile ); break ; case "image/png" : $this_file_type = ".png" ; $src = imagecreatefrompng( $storeduploadedfile ); break ; } // END THE SWITCH $named = $uploaded_file [ 'name' ]; $named = preg_replace( '/[^A-Za-z0-9\.]/' , "" , $named ); /////////////////////////////////////////////////////////////////////////////////// // MID SIZE IMAGE // list( $width , $height )= getimagesize ( $storeduploadedfile ); $original_width = $width ; $original_height = $height ; $ratio = $width / $height ; if ( $width > 1000) { // 850AM $width = 1000; $height = 1000 / $ratio ; } // 850AM $mid_size =imagecreatetruecolor( $width , $height ); imagecopyresampled( $mid_size , $src ,0,0,0,0, $width , $height , $original_width , $original_height ); $mid_filename = dirname( __FILE__ ) . "/member_images/$members_ID/mid_size_{$named}" ; imagejpeg( $mid_size , $mid_filename ,100); $return [ 'mid_size' ] = get_bloginfo( 'template_directory' ). "/member_images/$members_ID/mid_size_" . $named ; // MID SIZE IMAGE // /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// // SMALL SIZE IMAGE // list( $width , $height )= getimagesize ( $storeduploadedfile ); $original_width = $width ; $original_height = $height ; $ratio = $width / $height ; if ( $width > 330) { // 850AM $width = 330; $height = 330 / $ratio ; } // 850AM $small_size =imagecreatetruecolor( $width , $height ); imagecopyresampled( $small_size , $src ,0,0,0,0, $width , $height , $original_width , $original_height ); $small_filename = dirname( __FILE__ ) . "/member_images/$members_ID/small_size_{$named}" ; imagejpeg( $small_size , $small_filename ,100); $return [ 'small_size' ] = get_bloginfo( 'template_directory' ). "/member_images/$members_ID/small_size_" . $named ; // SMALL SIZE IMAGE // /////////////////////////////////////////////////////////////////////////////////// if (move_uploaded_file( $uploaded_file [ 'tmp_name' ], dirname( __FILE__ ) . "/member_images/$members_ID/$named" )) { } else { } } else { switch ( $uploaded_file [ 'error' ]) { case 1: $update_status = "<div id=\"pic_update_div\" style=\"border-color:red;\"><span id=\"all_bad\">File is too big!</span></div>" ; break ; case 2: $update_status = "<div id=\"pic_update_div\" style=\"border-color:red;\"><span id=\"all_bad\">File is too big!</span></div>" ; break ; case 3: $update_status = "<div id=\"pic_update_div\" style=\"border-color:red;\"><span id=\"all_bad\">File partialy loaded!</span></div>" ; break ; case 4: $update_status = "<div id=\"pic_update_div\" style=\"border-color:red;\"><span id=\"all_bad\">No file was uploaded!</span></div>" ; break ; case 6: $update_status = "<div id=\"pic_update_div\" style=\"border-color:red;\"><span id=\"all_bad\">No temp folder available!</span></div>" ; break ; default : $update_status = "<div id=\"pic_update_div\" style=\"border-color:red;\"><span id=\"all_bad\">Please upload a JPG or GIF!</span></div>" ; break ; } // END THE SWITCH } // END ELSE FOR if (in_array($_FILES['file_to_upload']['type'], $allowed)) { $return [ 'full_size' ] = get_bloginfo( 'template_directory' ). "/member_images/$members_ID/{$named}" ; return $return ; } // 629AM |