Changeset 2917477
- Timestamp:
- 05/25/2023 06:26:36 PM (20 months ago)
- Location:
- frontend-registration-contact-form-7/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend-registration-contact-form-7/trunk/css/style.css
r2182032 r2917477 857 857 .border td{border: 1px solid #cccccc;padding-left: 10px;} 858 858 #additionalsettings-registration{border: 2px solid #949494;border-radius: 15px;padding: 10px;} 859 859 860 .checkbox-settings{display: block;margin: 20px 0 20px 0; border-radius: 10px;background-color: #e2e2e2b5; padding: 20px;} -
frontend-registration-contact-form-7/trunk/frontend-registration-cf7.php
r2878516 r2917477 1 1 <?php 2 2 /** 3 * Plugin Name: Frontend Registration - Contact Form 7 3 * Plugin Name: Frontend Registration - Contact Form 7 4 4 * Plugin URL: http://www.wpbuilderweb.com/frontend-registration-contact-form-7/ 5 * Description: This plugin will convert your Contact form 7 in to registration form for WordPress. PRO Plugin available now with New Features. <strong>PRO Version is also available with New Features.</strong>.6 * Version: 4.55 * Description: This plugin will convert your Contact form 7 in to registration form for WordPress. 6 * Version: 7 7 * Author: David Pokorny 8 * Author URI: http://www.wpbuilderweb.com 8 * Author URI: http://www.wpbuilderweb.com 9 9 * Developer: Pokorny David 10 10 * Developer E-Mail: pokornydavid4@gmail.com … … 25 25 exit; // Exit if accessed directly 26 26 } 27 28 define( 'FRCF7_VERSION', '4.5' ); 29 30 define( 'FRCF7_REQUIRED_WP_VERSION', '4.0' ); 27 define( 'FRCF7_VERSION', '5.0' ); 31 28 32 29 define( 'FRCF7_PLUGIN', __FILE__ ); … … 40 37 define( 'FRCF7_PLUGIN_CSS_DIR', FRCF7_PLUGIN_DIR . '/css' ); 41 38 39 40 41 42 42 require_once (dirname(__FILE__) . '/frontend-registration-opt-cf7.php'); 43 44 function cf7fr_editor_panels_reg ( $panels ) { 45 46 $new_page = array( 47 'Error' => array( 48 'title' => __( 'Registration Settings', 'contact-form-7' ), 49 'callback' => 'cf7fr_admin_reg_additional_settings' 50 ) 51 ); 52 53 $panels = array_merge($panels, $new_page); 54 55 return $panels; 56 57 } 58 add_filter( 'wpcf7_editor_panels', 'cf7fr_editor_panels_reg' ); 59 60 add_filter('plugin_row_meta', 'my_register_plugins_link', 10, 2); 61 function my_register_plugins_link ($links, $file) { 62 $base = plugin_basename(__FILE__); 63 if ($file == $base) { 64 $links[] = '<a href="http://www.wpbuilderweb.com/frontend-registration-contact-form-7/">' . __('PRO Version') . '</a>'; 65 $links[] = '<a href="http://www.wpbuilderweb.com/shop">' . __('More Plugins by David Pokorny') . '</a>'; 66 //$links[] = '<a href="http://www.wpbuilderweb.com/payment/">' . __('Donate') . '</a>'; 67 } 68 return $links; 69 } 70 function cf7fr_admin_reg_additional_settings( $cf7 ) 71 { 72 73 $post_id = sanitize_text_field($_GET['post']); 74 $tags = $cf7->scan_form_tags(); 75 $cf7frenable = get_post_meta($post_id, "_cf7fr_enable_registration", true); 76 $cf7fru = get_post_meta($post_id, "_cf7fru_", true); 77 $cf7fre = get_post_meta($post_id, "_cf7fre_", true); 78 $cf7frr = get_post_meta($post_id, "_cf7frr_", true); 79 $enablemail = get_post_meta($post_id, "_cf7fr_enablemail_registration", true); 80 $autologinfield = get_post_meta($post_id, "_cf7fr_autologinfield_reg", true); 81 $loginurlmail = get_post_meta($post_id, "_cf7fr_loginurlmail_reg", true); 82 $loginurlformail = get_post_meta($post_id, "_cf7fr_loginurlformail_reg", true); 83 $selectedrole = $cf7frr; 84 if(!$selectedrole) 85 { 86 $selectedrole = 'subscriber'; 87 } 88 if ($cf7frenable == "1") { $cf7frechecked = "CHECKED"; } else { $cf7frechecked = ""; } 89 if ($enablemail == "1") { $checkedmail = "CHECKED"; } else { $checkedmail = ""; } 90 if ($autologinfield == "1") { $autologinfield = "CHECKED"; } else { $autologinfield = ""; } 91 if ($loginurlmail == "1") { $loginurlmail = "CHECKED"; } else { $loginurlmail = ""; } 92 if ($loginurlformail != "") { $loginurlformail = $loginurlformail; } else { $loginurlformail = ""; } 93 94 $selected = ""; 95 $admin_cm_output = ""; 96 97 $admin_cm_output .= "<div id='additional_settings-sortables' class='meta-box'><div id='additionalsettingsdiv'>"; 98 $admin_cm_output .= "<h2 class='hndle ui-sortable-handle'><span>Frontend Registration Settings:</span></h2>"; 99 $admin_cm_output .= "<div class='inside'>"; 100 101 $admin_cm_output .= "<div class='mail-field pretty p-switch p-fill'>"; 102 $admin_cm_output .= "<input name='cf7frenable' value='1' type='checkbox' $cf7frechecked>"; 103 $admin_cm_output .= "<div class='state'><label>Enable Registration on this form</label></div>"; 104 $admin_cm_output .= "</div>"; 105 106 $admin_cm_output .= "<div class='mail-field pretty p-switch p-fill'>"; 107 $admin_cm_output .= "<input name='enablemail' value='' type='checkbox' $checkedmail>"; 108 $admin_cm_output .= "<div class='state'><label>Skip Contact Form 7 Mails ?</label></div>"; 109 $admin_cm_output .= "</div>"; 110 111 $admin_cm_output .= "<div class='mail-field pretty p-switch p-fill'>"; 112 $admin_cm_output .= "<input name='autologinfield' value='' type='checkbox' $autologinfield>"; 113 $admin_cm_output .= "<div class='state'><label>Enable auto login after registration? </label></div>"; 114 $admin_cm_output .= "</div>"; 115 116 $admin_cm_output .= "<div class='mail-field pretty p-switch p-fill'>"; 117 $admin_cm_output .= "<input name='loginurlmail' value='' type='checkbox' $loginurlmail>"; 118 $admin_cm_output .= "<div class='state'><label>Enable sent Login URL in Mail. </label></div>"; 119 $admin_cm_output .= "</div>"; 120 121 $admin_cm_output .= "<div class='mail-field'>"; 122 $admin_cm_output .= "<br/><div class='state'><label>Set Custom Login URL for email :</label></div>"; 123 $admin_cm_output .= "<input name='loginurlformail' value='".$loginurlformail."' type='text' ><br/>"; 124 $admin_cm_output .= "</div>"; 125 126 $admin_cm_output .= "<table>"; 127 128 $admin_cm_output .= "<div class='handlediv' title='Click to toggle'><br></div><h2 class='hndle ui-sortable-handle'><span>Frontend Fields Settings:</span></h2>"; 129 130 $admin_cm_output .= "<tr><td>Selected Field Name For User Name :</td></tr>"; 131 $admin_cm_output .= "<tr><td><select name='_cf7fru_'>"; 132 $admin_cm_output .= "<option value=''>Select Field</option>"; 133 foreach ($tags as $key => $value) { 134 if($cf7fru==$value['name']){$selected='selected=selected';}else{$selected = "";} 135 $admin_cm_output .= "<option ".$selected." value='".$value['name']."'>".$value['name']."</option>"; 136 } 137 $admin_cm_output .= "</select>"; 138 $admin_cm_output .= "</td></tr>"; 139 140 $admin_cm_output .= "<tr><td>Selected Field Name For Email :</td></tr>"; 141 $admin_cm_output .= "<tr><td><select name='_cf7fre_'>"; 142 $admin_cm_output .= "<option value=''>Select Field</option>"; 143 foreach ($tags as $key => $value) { 144 if($cf7fre==$value['name']){$selected='selected=selected';}else{$selected = "";} 145 $admin_cm_output .= "<option ".$selected." value='".$value['name']."'>".$value['name']."</option>"; 146 } 147 $admin_cm_output .= "</select>"; 148 $admin_cm_output .= "</td></tr><tr><td>"; 149 $admin_cm_output .= "<input type='hidden' name='email' value='2'>"; 150 $admin_cm_output .= "<input type='hidden' name='post' value='$post_id'>"; 151 $admin_cm_output .= "</td></tr>"; 152 $admin_cm_output .= "<tr><td>Selected User Role:</td></tr>"; 153 $admin_cm_output .= "<tr><td>"; 154 $admin_cm_output .= "<select name='_cf7frr_'>"; 155 $editable_roles = get_editable_roles(); 156 foreach ( $editable_roles as $role => $details ) { 157 $name = translate_user_role($details['name'] ); 158 if ( $selectedrole == $role ) // preselect specified role 159 $admin_cm_output .= "<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; 160 else 161 $admin_cm_output .= "<option value='" . esc_attr($role) . "'>$name</option>"; 162 } 163 $admin_cm_output .="</select>"; 164 $admin_cm_output .= "</td></tr>"; 165 $admin_cm_output .="</table>"; 166 $admin_cm_output .= "</div>"; 167 $admin_cm_output .= "</div>"; 168 $admin_cm_output .= "</div>"; 169 170 echo $admin_cm_output; 171 172 } 173 // hook into contact form 7 admin form save 174 add_action('wpcf7_save_contact_form', 'cf7_save_reg_contact_form'); 175 176 177 function cf7_save_reg_contact_form( $cf7 ) { 178 179 $tags = $cf7->scan_form_tags(); 180 181 182 $post_id = sanitize_text_field($_POST['post_ID']); 183 184 if (!empty($_POST['cf7frenable'])) { 185 $enable = sanitize_text_field($_POST['cf7frenable']); 186 update_post_meta($post_id, "_cf7fr_enable_registration", $enable); 187 } else { 188 update_post_meta($post_id, "_cf7fr_enable_registration", 0); 189 } 190 if (isset($_POST['enablemail'])) { 191 update_post_meta($post_id, "_cf7fr_enablemail_registration", 1); 192 } else { 193 update_post_meta($post_id, "_cf7fr_enablemail_registration", 0); 194 } 195 196 if (isset($_POST['autologinfield'])) { 197 update_post_meta($post_id, "_cf7fr_autologinfield_reg", 1); 198 } else { 199 update_post_meta($post_id, "_cf7fr_autologinfield_reg", 0); 200 } 201 202 if (isset($_POST['loginurlmail'])) { 203 update_post_meta($post_id, "_cf7fr_loginurlmail_reg", 1); 204 } else { 205 update_post_meta($post_id, "_cf7fr_loginurlmail_reg", 0); 206 } 207 208 if (isset($_POST['loginurlformail'])) { 209 update_post_meta($post_id, "_cf7fr_loginurlformail_reg", sanitize_text_field($_POST['loginurlformail'])); 210 } else { 211 update_post_meta($post_id, "_cf7fr_loginurlformail_reg", ""); 212 } 213 214 $key = "_cf7fru_"; 215 $vals = sanitize_text_field($_POST[$key]); 216 update_post_meta($post_id, $key, $vals); 217 218 $key = "_cf7fre_"; 219 $vals = sanitize_text_field($_POST[$key]); 220 update_post_meta($post_id, $key, $vals); 221 222 $key = "_cf7frr_"; 223 $vals = sanitize_text_field($_POST[$key]); 224 update_post_meta($post_id, $key, $vals); 225 } 226 ?> 43 require_once (dirname(__FILE__) . '/frontend-registration-activation-cf7.php'); 44 require_once (dirname(__FILE__) . '/frontend-registration-login-cf7.php'); 45 require_once (dirname(__FILE__) . '/frontend-registration-admin-cf7.php'); -
frontend-registration-contact-form-7/trunk/frontend-registration-opt-cf7.php
r2673803 r2917477 7 7 exit; // Exit if accessed directly 8 8 } 9 add_action('admin_enqueue_scripts', 'callback_frcf7_setting_up_scripts'); 10 function callback_frcf7_setting_up_scripts() { 11 wp_enqueue_style( 'frcf7css', frcf7_plugin_url('/css/style.css'), array(), FRCF7_VERSION, 'all' ); 12 } 9 10 if(isset($_GET['key']) && isset($_GET['action'])){ 11 global $wpdb; 12 $retID = $wpdb->get_results("SELECT ID FROM $wpdb->users WHERE user_activation_key = '".$_GET['key']."'"); 13 14 if($retID){ 15 $userid = $retID[0]->ID; 16 $wpdb->query("UPDATE $wpdb->usermeta SET meta_value = 0 WHERE meta_key='cf7fu_disable_user' and user_id=".$userid); 17 $wpdb->query("UPDATE $wpdb->users SET user_activation_key = '' WHERE ID=".$retID[0]->ID); 18 } 19 } 20 function frcf7_plugin_url( $path = '' ) { 21 $url = plugins_url( $path, FRCF7_PLUGIN ); 22 23 if ( is_ssl() 24 and 'http:' == substr( $url, 0, 5 ) ) { 25 $url = 'https:' . substr( $url, 5 ); 26 } 27 28 return $url; 29 } 30 31 function create_user_from_registration($cfdata) { 32 global $wpcf7,$loginlink; 33 34 $post_id = sanitize_text_field($_POST['_wpcf7']); 35 $cf7fru = get_post_meta($post_id, "_cf7fru_", true); 36 $cf7fre = get_post_meta($post_id, "_cf7fre_", true); 37 $returnfieldarr = filterarray(); 38 foreach ($returnfieldarr as $key => $value) { 39 $cf7 = $value; 40 $$cf7 = get_post_meta($post_id, "_cf7".$value."_", true); 41 } 42 $cf7frr = get_post_meta($post_id, "_cf7frr_", true); 43 $cf7frel = get_post_meta($post_id, "_cf7frel_", true); 44 $cf7rarg = get_post_meta($post_id, "_cf7rarg_", true); 45 46 $passwordfield = get_post_meta($post_id, "_cf7fr_passwordfield_registration", true); 47 $activationfield = get_post_meta($post_id, "_cf7fr_activationfield_reg", true); 48 $autologinfield = get_post_meta($post_id, "_cf7fr_autologinfield_reg", true); 49 $redirectafterreg = get_post_meta($post_id, "_cf7fr_redirectafterreg_reg", true); 50 if ($autologinfield == "1") { $activationfield = ""; } 51 $cf7frp = get_post_meta($post_id, "_cf7frp_", true); 52 53 $enable = get_post_meta($post_id,'_cf7fr_enable_registration'); 54 if($enable[0]!=0) 55 { 56 if (!isset($cfdata->posted_data) && class_exists('WPCF7_Submission')) { 57 $submission = WPCF7_Submission::get_instance(); 58 if ($submission) { 59 $formdata = $submission->get_posted_data(); 60 } 61 } elseif (isset($cfdata->posted_data)) { 62 $formdata = $cfdata->posted_data; 63 } 64 if($cf7fre != ''){ $email = $formdata["".$cf7fre.""]; } 65 if($cf7fru != ''){ $name = $formdata["".$cf7fru.""]; } 66 if($cf7frp != ''){ $pass = $formdata["".$cf7frp.""]; } 67 if($activationfield=="1"){$user_status = 1;}else{$user_status=0;} 68 // Construct a username from the user's name 69 $username = strtolower(str_replace(' ', '', $name)); 70 $name_parts = explode(' ',$name); 71 if ( !email_exists( $email ) ) 72 { 73 //Find an unused username 74 $username_tocheck = $username; 75 $i = 1; 76 while ( username_exists( $username_tocheck ) ) { 77 $username_tocheck = $username . $i++; 78 } 79 $username = $username_tocheck; 80 $user_email = $email; 81 // Create the user 82 83 foreach ($returnfieldarr as $key => $value) { 84 $cf7 = $value; 85 $key = "_cf7".$value."_"; 86 $cf7 = get_post_meta($post_id, $key, true); 87 if($value != '' && $cf7 != ''){ 88 $dynamicarray[$value] = $formdata[$cf7]; 89 } 90 } 91 92 if($passwordfield =="1"){ 93 $password = $pass; 94 }else{ 95 $password = wp_generate_password( 12, false ); 96 } 97 // Create the user 98 $userdata = array( 99 'user_login' => $username, 100 'user_pass' => $password, 101 'user_email' => $email, 102 'role' => $cf7frr 103 ); 104 $mergeuserdata = array_merge($dynamicarray,$userdata); 105 $user_id = wp_insert_user( wp_slash ( $mergeuserdata ) ); 106 107 if($user_id) 108 { 109 if($dynamicarray){ 110 foreach ($dynamicarray as $key => $value) { 111 if(substr($key, 0,1)=="_"){ 112 $field_name = str_replace("_","",$key); 113 $fieldkey = acf_get_field_key($field_name); 114 update_user_meta( $user_id, $key, $fieldkey ); 115 update_user_meta( $user_id, $field_name, $value ); 116 }else{ 117 update_user_meta( $user_id, $key, $value ); 118 } 119 } 120 } 121 update_user_meta( $user_id, 'cf7fu_disable_user', $user_status ); 122 } 123 if(!$cf7frel) 124 { 125 $loginlink = esc_url(wp_login_url()); 126 } 127 else 128 { 129 $loginlink = esc_url($cf7frel); 130 } 131 132 if($activationfield == "1"){ 133 if ( $user_id && !is_wp_error( $user_id ) ) { 134 $salt = wp_generate_password(20); 135 $code = sha1($salt . $user_email . uniqid(time(), true)); 136 global $wpdb; 137 $wpdb->query("UPDATE $wpdb->users SET user_activation_key = '".$code."' WHERE ID=".$user_id); 138 $cf7frap = get_post_meta($post_id, "_cf7frap_", true); 139 if(isset($cf7frap)){ 140 $activation_URL = esc_url($cf7frap); 141 }else{ 142 $activation_URL = esc_url(get_site_url()); 143 } 144 $activation_link = add_query_arg( array( 'key' => $code, 'action' => 'act' ), $activation_URL); 145 sendEmailToUserInactive($post_id, $user_email, $username , $activation_link, $loginlink, $password); 146 } 147 148 }else{ 149 if ( !is_wp_error($user_id) ) { 150 // Email login details to user 151 sendEmailToUser($post_id, $email, $username, $loginlink, $password); 152 } 153 } 154 if ($autologinfield == "1") { 155 156 $user = get_user_by( 'id', $user_id ); 157 158 if( $user ) { 159 wp_set_current_user( $user_id, $user->user_login ); 160 wp_set_auth_cookie( $user_id ); 161 do_action( 'wp_login', $user->user_login ); 162 163 } 164 165 } 166 } 167 168 } 169 return $cfdata; 170 } 171 add_action('wpcf7_before_send_mail', 'create_user_from_registration', 1, 2); 172 function your_validation_text_func( $result, $tag ) 173 { 174 global $wpcf7; 175 $post_id = sanitize_text_field($_POST['_wpcf7']); 176 $cf7fru = get_post_meta($post_id, "_cf7fru_", true); 177 $tag = new WPCF7_FormTag( $tag ); 178 $type = $tag->type; 179 $name = $tag->name; 180 global $wpdb; 181 if(isset($_POST[''.$cf7fru.'']) && $_POST[''.$cf7fru.'']!="") 182 { 183 if($name =="".$cf7fru."") 184 { 185 $username = $_POST[''.$cf7fru.'']; 186 if(username_exists($username)) 187 { 188 $result->invalidate($tag, __( 'Username already registered!.', 'contact-form-7-freg' )); 189 190 } 191 192 } 193 } 194 195 return $result; 196 } 197 add_filter( 'wpcf7_validate_text*', 'your_validation_text_func', 20, 2 ); 198 function your_validation_password_func( $result, $tag ) 199 { 200 global $wpcf7; 201 $tag = new WPCF7_FormTag( $tag ); 202 $type = $tag->type; 203 $name = $tag->name; 204 $name2 = $tag->name."-2"; 205 //global $wpdb; 206 if( isset($_POST[''.$name.'']) && $_POST[''.$name.'']=="" ) 207 { 208 $result->invalidate($tag, __( 'Please enter Password', 'contact-form-7-freg' )); 209 } 210 if( isset( $_POST[''.$name2.''] ) && $_POST[''.$name2.'']=="" ) 211 { 212 $result->invalidate($tag, __( 'Please enter Confirm Password', 'contact-form-7-freg' )); 213 } 214 if( $_POST[''.$name.''] != $_POST[''.$name2.'']) 215 { 216 // $result->invalidate( $tag, __( 'Password & Confirm Password do not match.', 'contact-form-7-freg' )); 217 $result['valid'] = false; 218 $result['reason'] = array( $name => sprintf( __( "Password & Confirm Password do not match.", 'contact-form-7-freg' ) ) ); 219 } 220 221 return $result; 222 } 223 add_filter( 'wpcf7_validate_password*', 'your_validation_password_func', 20, 2 ); 224 add_filter( 'wpcf7_validate_password', 'your_validation_password_func', 20, 2 ); 225 function your_validation_email_filter( $result, $tag ) 226 { 227 global $wpcf7; 228 $post_id = sanitize_text_field($_POST['_wpcf7']); 229 $cf7fre = get_post_meta($post_id, "_cf7fre_", true); 230 $tag = new WPCF7_FormTag( $tag ); 231 $type = $tag->type; 232 $name = $tag->name; 233 global $wpdb; 234 if(isset($_POST[''.$cf7fre.'']) && $_POST[''.$cf7fre.'']!="") 235 { 236 if($name =="".$cf7fre."") 237 { 238 $email = $_POST[''.$cf7fre.'']; 239 if(email_exists($email)) 240 { 241 $result->invalidate($tag, __( 'Email already registered!', 'contact-form-7-freg' )); 242 243 } 244 } 245 } 246 return $result; 247 } 248 add_filter( 'wpcf7_validate_email*', 'your_validation_email_filter', 20, 2 ); 249 add_filter( 'wpcf7_validate_email', 'your_validation_email_filter', 20, 2 ); 250 13 251 add_filter( 'wpcf7_skip_mail', function( $skip_mail, $contact_form ) { 14 252 $post_id = sanitize_text_field($_POST['_wpcf7']); … … 19 257 return $skip_mail; 20 258 }, 10, 2 ); 21 function frcf7_plugin_url( $path = '' ) { 22 $url = plugins_url( $path, FRCF7_PLUGIN ); 23 24 if ( is_ssl() 25 and 'http:' == substr( $url, 0, 5 ) ) { 26 $url = 'https:' . substr( $url, 5 ); 27 } 28 29 return $url; 30 } 31 function create_user_from_registration($cfdata) { 32 //$cmtagobj = new WPCF7_Shortcode( $tag ); 33 $post_id = sanitize_text_field($_POST['_wpcf7']); 34 $cf7fru = get_post_meta($post_id, "_cf7fru_", true); 35 $cf7fre = get_post_meta($post_id, "_cf7fre_", true); 259 function sendEmailToUser($post_id, $email, $username, $loginlink, $password) 260 { 261 $_cf7frfrom_ = get_post_meta($post_id, "_cf7frfrom_", true); 262 $_cf7frsub_ = get_post_meta($post_id, "_cf7frsub_", true); 263 $_cf7freb_ = get_post_meta($post_id, "_cf7freb_", true); 36 264 $cf7frr = get_post_meta($post_id, "_cf7frr_", true); 37 $autologinfield = get_post_meta($post_id, "_cf7fr_autologinfield_reg", true); 38 $enable = get_post_meta($post_id,'_cf7fr_enable_registration'); 39 $loginurlmail = get_post_meta($post_id, "_cf7fr_loginurlmail_reg", true); 40 $loginurlformail = get_post_meta($post_id, "_cf7fr_loginurlformail_reg", true); 41 if($enable[0]!=0) 42 { 43 if (!isset($cfdata->posted_data) && class_exists('WPCF7_Submission')) { 44 $submission = WPCF7_Submission::get_instance(); 45 if ($submission) { 46 $formdata = $submission->get_posted_data(); 47 } 48 } elseif (isset($cfdata->posted_data)) { 49 $formdata = $cfdata->posted_data; 50 } 51 $password = wp_generate_password( 12, false ); 52 $email = $formdata["".$cf7fre.""]; 53 $name = $formdata["".$cf7fru.""]; 54 // Construct a username from the user's name 55 $username = strtolower(str_replace(' ', '', $name)); 56 $name_parts = explode(' ',$name); 57 if ( !email_exists( $email ) ) 58 { 59 // Find an unused username 60 $username_tocheck = $username; 61 $i = 1; 62 while ( username_exists( $username_tocheck ) ) { 63 $username_tocheck = $username . $i++; 64 } 65 $username = $username_tocheck; 66 // Create the user 67 $userdata = array( 68 'user_login' => $username, 69 'user_pass' => $password, 70 'user_email' => $email, 71 'nickname' => reset($name_parts), 72 'display_name' => $name, 73 'first_name' => reset($name_parts), 74 'last_name' => end($name_parts), 75 'role' => $cf7frr 76 ); 77 $user_id = wp_insert_user( $userdata ); 78 if ( !is_wp_error($user_id) ) { 79 // Email login details to user 80 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 81 $message = "Welcome! Your login details are as follows:" . "\r\n"; 82 $message .= sprintf(__('Username: %s'), $username) . "\r\n"; 83 $message .= sprintf(__('Password: %s'), $password) . "\r\n"; 84 if($loginurlmail){ 85 if($loginurlformail != ""){ 86 $message .= $loginurlformail . "\r\n"; 87 }else{ 88 $message .= wp_login_url() . "\r\n"; 89 } 90 } 91 wp_mail($email, sprintf(__('[%s] Your username and password'), $blogname), $message); 92 } 93 if ($autologinfield == "1" && !is_wp_error($user_id)) { 94 95 $user = get_user_by( 'id', $user_id ); 96 97 if( $user ) { 98 wp_set_current_user( $user_id, $user->user_login ); 99 wp_set_auth_cookie( $user_id ); 100 do_action( 'wp_login', $user->user_login, $user ); 101 } 102 103 } 104 105 } 106 107 } 108 return $cfdata; 109 } 110 add_action('wpcf7_before_send_mail', 'create_user_from_registration', 1, 2); 265 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 266 $enablcustomemail = get_post_meta($post_id,'_cf7fr_enablcustomemail_registration'); 267 268 if($enablcustomemail[0]==1){ 269 $_cf7freb_ = str_replace("[login-user]",$username,$_cf7freb_); 270 $_cf7freb_ = str_replace("[login-user-name]",$username,$_cf7freb_); 271 $_cf7freb_ = str_replace("[login-password]",$password,$_cf7freb_); 272 $_cf7freb_ = str_replace("[site-name]",$blogname,$_cf7freb_); 273 $_cf7freb_ = str_replace("[login-link]",$loginlink,$_cf7freb_); 274 $_cf7freb_ = str_replace("[login-email]",$email,$_cf7freb_); 275 $_cf7freb_ = str_replace("[login-role]",$cf7frr,$_cf7freb_); 276 // Always set content-type when sending HTML email 277 $headers = "MIME-Version: 1.0" . "\r\n"; 278 $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 279 $headers .= 'From: '.$blogname.' <'.$_cf7frfrom_.'>' . "\r\n"; 280 $body = nl2br($_cf7freb_,false); 281 $body = html_entity_decode($body); 282 $message = '<html>'; 283 $message .= '<body>'; 284 $message .= $body; 285 $message .= '</body>'; 286 $message .= '</html>'; 287 wp_mail($email, sprintf(__('[%s] - '.$_cf7frsub_), $blogname), $message, $headers); 288 }else{ 289 $message = "Welcome! Your login details are as follows:" . "\r\n"; 290 $message .= sprintf(__('Username: %s'), $username) . "\r\n"; 291 $message .= sprintf(__('Password: %s'), $password) . "\r\n"; 292 $message .= $loginlink . "\r\n"; 293 wp_mail($email, sprintf(__('[%s] Your username and password', 'contact-form-7-freg'), $blogname), $message); 294 } 295 } 296 function sendEmailToUserInactive($post_id, $email, $username, $activationlink, $loginlink, $password){ 297 $_cf7frfrom_ = get_post_meta($post_id, "_cf7frfrom_", true); 298 $_cf7frsub_ = get_post_meta($post_id, "_cf7frsub_", true); 299 $_cf7freb_ = get_post_meta($post_id, "_cf7freb_", true); 300 $cf7frr = get_post_meta($post_id, "_cf7frr_", true); 301 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 302 $enablcustomemail = get_post_meta($post_id,'_cf7fr_enablcustomemail_registration'); 303 if($enablcustomemail[0]==1){ 304 $_cf7freb_ = str_replace("[login-user]",$username,$_cf7freb_); 305 $_cf7freb_ = str_replace("[login-user-name]",$username,$_cf7freb_); 306 $_cf7freb_ = str_replace("[login-password]",$password,$_cf7freb_); 307 $_cf7freb_ = str_replace("[site-name]",$blogname,$_cf7freb_); 308 $_cf7freb_ = str_replace("[activation-link]",$activationlink,$_cf7freb_); 309 $_cf7freb_ = str_replace("[login-email]",$email,$_cf7freb_); 310 $_cf7freb_ = str_replace("[login-link]",$loginlink,$_cf7freb_); 311 $_cf7freb_ = str_replace("[login-role]",$cf7frr,$_cf7freb_); 312 // Always set content-type when sending HTML email 313 $headers = "MIME-Version: 1.0" . "\r\n"; 314 $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 315 $headers .= 'From: '.$blogname.' <'.$_cf7frfrom_.'>' . "\r\n"; 316 $body = nl2br($_cf7freb_,false); 317 $body = html_entity_decode($body); 318 $message = '<html>'; 319 $message .= '<body>'; 320 $message .= $body; 321 $message .= '</body>'; 322 $message .= '</html>'; 323 wp_mail($email, sprintf(__('[%s] - '.$_cf7frsub_), $blogname), $message, $headers); 324 }else{ 325 $message = "Welcome! Your login details are as follows:" . "\r\n"; 326 $message .= sprintf(__('Username: %s'), $username) . "\r\n"; 327 $message .= sprintf(__('Password: %s'), $password) . "\r\n"; 328 $message .= $activationlink . "\r\n"; 329 wp_mail($email, sprintf(__('[%s] Your username and password', 'contact-form-7-freg' ), $blogname), $message); 330 } 331 } 332 function acf_field_key($field_name, $post_id = false){ 333 334 if ( $post_id ) 335 return get_field_reference($field_name, $post_id); 336 337 if( !empty($GLOBALS['acf_register_field_group']) ) { 338 339 foreach( $GLOBALS['acf_register_field_group'] as $acf ) : 340 341 foreach($acf['fields'] as $field) : 342 343 if ( $field_name === $field['name'] ) 344 return $field['key']; 345 346 endforeach; 347 348 endforeach; 349 } 350 return $field_name; 351 } 352 function acf_get_field_key( $field_name ) { 353 global $wpdb; 354 $result = $wpdb->get_results("SELECT * from ".$wpdb->prefix."postmeta WHERE meta_value like '%".$field_name."%' AND meta_key like '%field_%'"); 355 return $result[0]->meta_key; 356 } 357 //This function prints the JavaScript to the footer 358 function cf7_footer_script(){ ?> 359 <script> 360 document.addEventListener( 'wpcf7mailsent', function( event ) { 361 location = '<?php echo $url = get_option( '_cf7rarg_' ) ? get_option( '_cf7rarg_' ) : get_home_url(); ?>'; 362 }, false ); 363 </script> 364 <?php } 365 add_action('wp_footer', 'cf7_footer_script'); 111 366 ?> -
frontend-registration-contact-form-7/trunk/readme.txt
r2878516 r2917477 1 1 === Frontend Registration - Contact Form 7 === 2 2 Contributors: pokornydavid 3 Tags: Contact Form 7, form, forms, registration, contactform7, Woocommerce, woo-commerce fields, Usermeta field, contact form, submit, Contact Forms 7, Contact Form 7 + Registration,Contact Forms, contacted, contacts, integrate Frontend Registration with contact form 7, Change Contact Form 7 in Registration form , signup form3 Tags: Contact Form 7, form, forms,, Change Contact Form 7 in Registration form , signup form 4 4 Donate link: http://#/payment/ 5 Requires at least: 5.x.x6 Tested up to: 6.1. 17 Stable tag: 4.55 Requires at least: 6 Tested up to: 6.1. 7 Stable tag: 8 8 License: GPLv3 or later License 9 9 Contact Form 7 requires at least: 3.0 10 Contact Form 7 tested up to: 5. x11 Version: 4.510 Contact Form 7 tested up to: 5.x 11 Version: 12 12 License URI: http://www.gnu.org/licenses/gpl-3.0.html 13 13 … … 16 16 == Description == 17 17 18 Contact Form 7 (CF7) is the most reliable WordPress Plugin used by the millions of user. Now a day's so many add-on are available for Contact form 7.18 Contact Form 7 (CF7) is . Now a day's so many add-on are available for Contact form 7. 19 19 20 We have created same like one add on for contact from 7 inwhich you can convert contact from 7 into registration form or signup form for WordPress user.20 We have created same like one add on for contact from 7 which you can convert contact from 7 into registration form or signup form for WordPress user. 21 21 22 By using this plugin you can create registration form by which registered user will be register as a subscriber rolein WordPress.22 By using this plugin you can create registration form in WordPress. 23 23 24 You just need to add plugin and select fields for username and email IDfrom created fields. In order to use this plugin, make sure your Contact Form 7 is activated.24 You just need to add plugin and select fields for username and email from created fields. In order to use this plugin, make sure your Contact Form 7 is activated. 25 25 26 = Contact Form 7 - Frontend Registration Form Features List =27 26 28 * You can convert your Contact form 7 form into registration form. 29 * Allows you to set fields for user name and email from admin settings. 30 * Plugin can work in multiple forms on different page or single page. 31 * You can select particular user role for the registration from settings. 32 * You can skip default email of Contact form 7 Pro. 27 = CF7 - Frontend Registration Features = 33 28 34 = Contact Form 7 - Frontend Registration Pro 4.9 Plug-in Features = 35 * We have provide restriction of same name and email with registrations. 36 * Also provide field for add link of login page if you are create custom login page. 37 * You can customize your registration mail which will be send to user with registration information. 38 * Easy understanding all setting from admin side. 39 * Also you can configured multiple Contact form 7 Pro for registration. 40 * Ability to set each and every different setting for different forms. 41 * Now you can set Password field from amdin. 42 * So User can their own password from frontend registration form. 43 * New feature with User meta field. Now you can assign your field to User meta fields , Also If you make extra user meta field then also supports. 44 * We have also supports Woocommerc Fields, Just make same field in contact for 7 and assign it to perticular Fields of Woocommerce. 45 * In custome field we have support with ACF fields only. You can assign Text field and Select Field to user page that can manage at the time of registration on contact Form 7. 46 47 = For Pro Version Vist Our site = 48 <strong>[For Contact 7- PayPal Extension Pro](http://www.wpbuilderweb.com/product/frontend-registration-contact-form-7-pro/)</strong> 49 <strong>[Shop More Products](http://www.wpbuilderweb.com/shop/)</strong> 29 * You can convert your Contact form 7 form into registration form. 30 * Allows you to set fields for user name and email from admin settings. 31 * Plugin can work in multiple forms on different page or single page. 32 * Now you can assign field to user meta created by ACF (Advance custom Field) plugin. 50 33 51 34 == Plugin Requirement == 52 35 53 36 PHP version : 5.3 and latest 54 WordPress : Wordpress 5.0 and latest37 WordPress : Wordpress .0 and latest 55 38 56 39 == Installation == … … 75 58 Yes, you can use it in multiple forms. Every from has different option and you can set fields for each and every forms although if it is in single page. 76 59 60 61 62 63 77 64 == Screenshots == 78 1. Screenshot 'screenshot-1.png' Shows 'registration settings' tab in contact form edit section. 79 2. Screenshot 'screenshot-2.png' Shows User Role change option in settings. 80 65 1. Screenshot 'screenshot-1.png' shows 'registration settings' tab in contact form edit section. 66 2. Screenshot 'screenshot-2.png' shows 'registration settings' tab with new options and fields. 81 67 == Changelog == 82 83 = 4.5 =84 * Tested with latest Contact Form 7 & WP.85 * Fix: Solve some minor bugs.86 87 = 4.4 =88 * Tested with latest Contact Form 7 with major update by them.89 * Tested with latest WordPress version.90 91 = 4.3 =92 * Set Option for Login URL Enable/Disable and Custom URL.93 94 = 4.2 =95 * Solved Redirection issue and tested with latest WP version.96 97 = 4.1 =98 * Solved some issue related to Site Health.99 100 = 4.0 =101 * Add New Feature of AutoLogin. After Registration its auto login and redirect on Home Page.102 103 = 3.3 =104 * Changes in GUI of Registration Setting and changes in some variable to make compitible with another plugin.105 106 = 3.1 =107 * Changes in GUI of Registration Setting with Contact form 7108 109 = 3.0 =110 * Add New feature for Free version , Now you can Skip defaul Contact form 7 Email.111 112 = 2.1 =113 * Add New feature for PRO version , Update detail in Free Plugin for Information.114 115 = 2.0 =116 * Add New feature for add user role from admin117 68 118 69 = 1.0 = 119 70 * Initial Release 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
Note: See TracChangeset
for help on using the changeset viewer.