PluginProbe
Pie Register – User Registration, Profiles & Content Restriction / trunk
Pie Register – User Registration, Profiles & Content Restriction vtrunk
3.8.4.12 3.8.4.11 3.7.4.2 3.7.4.3 3.7.4.4 3.7.4.5 3.7.4.6 3.7.5 3.7.5.1 3.8 3.8.0.1 3.8.0.2 3.8.1 3.8.1.1 3.8.1.2 3.8.1.3 3.8.1.4 3.8.2 3.8.2.1 3.8.2.2 3.8.2.3 3.8.2.4 3.8.2.5 3.8.2.6 3.8.2.7 All 178 releases
pie-register / classes / profile_front.php

profile_front.php in Pie Register – User Registration, Profiles & Content Restriction trunk, at classes/profile_front.php

427 lines 18.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 if( file_exists( dirname(__FILE__) . '/base.php') )
8 require_once('base.php');
9 class Profile_front extends PieReg_Base
10 {
11 var $field;
12 var $user_id;
13 var $slug;
14 var $type;
15 var $name;
16 var $id;
17 var $data;
18 var $user;
19
20 function __construct($user,$form_id = "default")
21 {
22 $this->data = $this->getCurrentFields($form_id);
23 $this->user = $user;
24 $this->user_id = $user->ID;
25
26 parent::__construct();
27 }
28
29 function createFieldName($text)
30 {
31 return "pie_".$this->getMetaKey($text);
32 }
33
34 function createFieldID()
35 {
36 return "field_" . ((isset($this->field['id']))?$this->field['id']:"");
37 }
38
39 function addLabel()
40 {
41 return '<label for="' . esc_attr($this->id) . '">' . esc_html($this->field['label']) . '</label>';
42 }
43
44 function print_user_profile($form_id = "default")
45 {
46 $data = "";
47 if (is_array($this->data) && sizeof($this->data) > 0)
48 {
49 $data .= '<div class="piereg_profile_cont">';
50 $data .= '<span class="piereg-profile-logout-url"><a href="'.esc_url(wp_logout_url()).'">'.esc_html__("Logout","pie-register").'</a></span>';
51 $option = get_option(OPTION_PIE_REGISTER);
52 $profile_page = $option['alternate_profilepage'];
53 if($profile_page > 0){
54 $data .= '<a class="piereg_edit_profile_link" href="' . esc_url( (add_query_arg( array("edit_user" => "1"), get_permalink($profile_page) )) ) . '"></a>';
55
56 $pie_pricing = get_user_meta($this->user_id,'pie_pricing',true);
57
58 if ( ($pie_pricing == 'PaypalStandard') && is_plugin_active('pie-register-paypal-recurring/pie-register-paypal-recurring.php') )
59 {
60 if ( ( $this->checkAddonActivated( 'PayPal_Recurring' ) == true ) && !isset($_GET['view_payments']) )
61 {
62 $data .= '<span class="piereg-profile-view-payments"> | <a href="' . esc_url( (add_query_arg( array("view_payments" => "true"), get_permalink($profile_page) )) ) . '">'.esc_html__("View Subscription","pie-register").'</a></span>';
63 }
64 else
65 {
66 $data .= '<span class="piereg-profile-view-profile"> | <a href="' . esc_url( get_permalink($profile_page) ) . '">'.esc_html__("View Profile","pie-register").'</a></span>';
67 }
68 }
69 else if ( is_plugin_active('pie-register-stripe-recurring/pie-register-stripe-recurring.php') )
70 {
71 if ( ( $this->checkAddonActivated( 'Stripe_Recurring' ) == true ) && !isset($_GET['view_payments']) )
72 {
73 $data .= '<span class="piereg-profile-view-payments"> | <a href="' . esc_url( (add_query_arg( array("view_payments" => "true"), get_permalink($profile_page) )) ) . '">'.esc_html__("View Payments","pie-register").'</a></span>';
74 }
75 else
76 {
77 $data .= '<span class="piereg-profile-view-profile"> | <a href="' . esc_url( get_permalink($profile_page) ) . '">'.esc_html__("View Profile","pie-register").'</a></span>';
78 }
79 }
80 }
81 if ( !isset($_GET['view_payments']) )
82 {
83 $data .= '<table border="0" cellpadding="0" cellspacing="0" class="pie_profile" id="pie_register">';
84
85 if(is_array($this->data)){
86 foreach ($this->data as $this->field)
87 {
88 $this->visibility_check = [true, true];
89 if($this->piereg_field_visbility_addon_active){
90 if(isset($this->field['show_on']) && !empty($this->field['show_on'])){
91 $this->visibility_check = apply_filters('pie_addon_field_visibility_conditions',$this->visibility_check,$this->field);
92 }
93
94 if(!$this->visibility_check[0])
95 {
96 continue;
97 }
98 }
99
100 if(isset($this->field['show_in_profile']) && $this->field['show_in_profile']=="0" && $this->visibility_check[1])
101 {
102 continue;
103 }
104
105 $this->slug = $this->createFieldName($this->field['type']."_".((isset($this->field['id']))?$this->field['id']:""));
106 $this->type = $this->field['type'];
107 $this->id = $this->createFieldID();
108 if($this->type=="default")
109 $this->slug = $this->field['field_name'];
110 /*
111 * Just Work 2Way Login Phone
112 */
113 elseif($this->type == "two_way_login_phone")
114 $this->slug = "piereg_two_way_login_phone";
115
116 //When to add label
117 switch($this->type) :
118 case 'password':
119 case 'form':
120 continue 2;
121 break;
122 case 'username' :
123 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
124 $data .= '</td><td class="fields"><span>'.esc_html($this->user->data->user_login).'</span></td></tr>';
125 break;
126 case 'email' :
127 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
128 $data .= '</td><td class="fields"><span>'.esc_html($this->user->data->user_email).'</span></td></tr>';
129 break;
130 case 'url':
131 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
132 $data .= '</td><td class="fields"><span>'.esc_url($this->getValue($this->type, $this->slug)).'</span></td></tr>';
133 break;
134 case 'name':
135 $this->slug = "first_name";
136 $data .= '<tr><td class="fields fields2"><label>'.esc_html($this->field['label'],"pie-register").'</label>';
137 $data .= '</td><td class="fields"><span>'.esc_html($this->getValue()).'</span></td></tr>';
138 if( !isset( $this->field['hide_last_name'] ) )
139 {
140 $this->slug = "last_name";
141 $data .= '<tr><td class="fields fields2"><label>'.esc_html($this->field['label2'],"pie-register").'</label>';
142 $data .= '</td><td class="fields"><span>'.esc_html($this->getValue()).'</span></td></tr>';
143 }
144 break;
145 case 'profile_pic':
146 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
147 $imgPath = (trim($this->getValue($this->type, $this->slug)) != "")? $this->getValue($this->type, $this->slug) : plugins_url("assets/images/userImage.png",dirname(__FILE__));
148 global $current_user;
149 $imgPath = apply_filters("piereg_profile_image_url",$imgPath,$current_user);
150 $data .= '</td><td class="fields"><span><img src="'.esc_url($imgPath).'" style="max-width:150px;" /></span></td></tr>';
151 break;
152 case 'upload':
153 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
154 $upload_file_value = $this->getValue($this->type, $this->slug);
155 $temp_dir = $this->piereg_get_uploaded_dir($this->user_id, $this->slug);
156 if(!file_exists($temp_dir."/".basename($upload_file_value))){
157 $upload_file_value = '';
158 }
159 $data .= '</td><td class="fields"><a class="uploaded_file" href="'.$upload_file_value.'" target="_blank">'.basename($upload_file_value).'</a></td></tr>';
160 break;
161 case 'address':
162 $data .= '<tr><td class="fields fields2" style="vertical-align:top;">'.wp_kses_post($this->addLabel());
163 $data .= '</td><td class="fields"><span>'.wp_kses_post($this->getValue($this->type, $this->slug)).'</span></td></tr>';
164 break;
165 //pie-register-WooCommerce Addon
166 case 'wc_billing_address':
167
168 if(isset($this->field['show_in_profile']) && $this->field['show_in_profile']=="1")
169 {
170 if ($this->woocommerce_and_piereg_wc_addon_active)
171 {
172 $label = "";
173
174 if ($this->field['label'])
175 {
176 $label = wp_kses_post($this->addLabel());
177 }
178 else
179 {
180 $label = '<label for="' . esc_attr($this->id) . '">' . esc_html__("Billing Address","pie-register") . '</label>';
181 }
182
183 $wc_billing_first_name = get_user_meta($this->user_id, "billing_first_name", true);
184 $wc_billing_last_name = get_user_meta($this->user_id, "billing_last_name", true);
185 $wc_billing_company = get_user_meta($this->user_id, "billing_company", true);
186 $wc_billing_address_1 = get_user_meta($this->user_id, "billing_address_1", true);
187 $wc_billing_address_2 = get_user_meta($this->user_id, "billing_address_2", true);
188 $wc_billing_city = get_user_meta($this->user_id, "billing_city", true);
189 $wc_billing_postcode = get_user_meta($this->user_id, "billing_postcode", true);
190 $wc_billing_country = get_user_meta($this->user_id, "billing_country", true);
191 $wc_billing_state = get_user_meta($this->user_id, "billing_state", true);
192 $wc_billing_email = get_user_meta($this->user_id, "billing_email", true);
193 $wc_billing_phone = get_user_meta($this->user_id, "billing_phone", true);
194
195 if (!empty($wc_billing_country))
196 {
197 global $woocommerce;
198 $countries_obj = new WC_Countries();
199 $states = $countries_obj->get_states($wc_billing_country);
200 $wc_billing_country = $countries_obj->countries[$wc_billing_country];
201 if ($states) {
202 if ( array_key_exists($wc_billing_state, $states) )
203 {
204 $wc_billing_state = $states[$wc_billing_state];
205 }
206 else
207 {
208 $wc_billing_state = "";
209 }
210 }
211 }
212
213 $data .= '<tr><td class="fields fields2" style="vertical-align:top;">'.wp_kses_post($label).'</td>';
214 $data .= '<td class="fields"><span>';
215
216 $data .= "<table class='woo_fields_profile' border='0' cellpadding='0' cellspacing='0'>";
217 $data .= "<tr>";
218 $data .= "<td style='width: 50%;'>First Name: </td><td>".esc_html($wc_billing_first_name)."</td>";
219 $data .= "</tr>";
220 $data .= "<tr>";
221 $data .= "<td style='width: 50%;'>Last Name: </td><td>".esc_html($wc_billing_last_name)."</td>";
222 $data .= "</tr>";
223 $data .= "<tr>";
224 $data .= "<td style='width: 50%;'>Company: </td><td>".esc_html($wc_billing_company)."</td>";
225 $data .= "</tr>";
226 $data .= "<tr>";
227 $data .= "<td style='width: 50%;'>Address Line 1: </td><td>".esc_html($wc_billing_address_1)."</td>";
228 $data .= "</tr>";
229 $data .= "<tr>";
230 $data .= "<td style='width: 50%;'>Address Line 2: </td><td>".esc_html($wc_billing_address_2)."</td>";
231 $data .= "</tr>";
232 $data .= "<tr>";
233 $data .= "<td style='width: 50%;'>City: </td><td>".esc_html($wc_billing_city)."</td>";
234 $data .= "</tr>";
235 $data .= "<tr>";
236 $data .= "<td style='width: 50%;'>Zipcode: </td><td>".esc_html($wc_billing_postcode)."</td>";
237 $data .= "</tr>";
238 $data .= "<tr>";
239 $data .= "<td style='width: 50%;'>Country: </td><td>".esc_html($wc_billing_country)."</td>";
240 $data .= "</tr>";
241 $data .= "<tr>";
242 $data .= "<td style='width: 50%;'>State: </td><td>".esc_html($wc_billing_state)."</td>";
243 $data .= "</tr>";
244 $data .= "<tr>";
245 $data .= "<td style='width: 50%;'>Email Address: </td><td>".esc_html($wc_billing_email)."</td>";
246 $data .= "</tr>";
247 $data .= "<tr>";
248 $data .= "<td style='width: 50%;'>Phone: </td><td>".esc_html($wc_billing_phone)."</td>";
249 $data .= "</tr>";
250 $data .= "</table>";
251
252 $data .= '</span></td></tr>';
253 }
254 }
255
256 break;
257 case 'wc_shipping_address':
258
259 if(isset($this->field['show_in_profile']) && $this->field['show_in_profile']=="1")
260 {
261 if ($this->woocommerce_and_piereg_wc_addon_active)
262 {
263 $label = "";
264
265 if ($this->field['label'])
266 {
267 $label = wp_kses_post($this->addLabel());
268 }
269 else
270 {
271 $label = '<label for="' . esc_attr($this->id) . '">' . esc_html__("Shipping Address","pie-register") . '</label>';
272 }
273
274 $wc_shipping_first_name = get_user_meta($this->user_id, "shipping_first_name", true);
275 $wc_shipping_last_name = get_user_meta($this->user_id, "shipping_last_name", true);
276 $wc_shipping_company = get_user_meta($this->user_id, "shipping_company", true);
277 $wc_shipping_address_1 = get_user_meta($this->user_id, "shipping_address_1", true);
278 $wc_shipping_address_2 = get_user_meta($this->user_id, "shipping_address_2", true);
279 $wc_shipping_city = get_user_meta($this->user_id, "shipping_city", true);
280 $wc_shipping_postcode = get_user_meta($this->user_id, "shipping_postcode", true);
281 $wc_shipping_country = get_user_meta($this->user_id, "shipping_country", true);
282 $wc_shipping_state = get_user_meta($this->user_id, "shipping_state", true);
283 $wc_shipping_email = get_user_meta($this->user_id, "shipping_email", true);
284 $wc_shipping_phone = get_user_meta($this->user_id, "shipping_phone", true);
285
286 if (!empty($wc_shipping_country))
287 {
288 global $woocommerce;
289 $countries_obj = new WC_Countries();
290 $states = $countries_obj->get_states($wc_shipping_country);
291 $wc_shipping_country = $countries_obj->countries[$wc_shipping_country];
292 if ($states) {
293 if ( array_key_exists($wc_shipping_state, $states) )
294 {
295 $wc_shipping_state = $states[$wc_shipping_state];
296 }
297 else
298 {
299 $wc_shipping_state = "";
300 }
301 }
302 }
303
304 $data .= '<tr><td class="fields fields2" style="vertical-align:top;">'.wp_kses_post($label).'</td>';
305 $data .= '<td class="fields"><span>';
306
307 $data .= "<table class='woo_fields_profile' id='woo_profile' border='0' cellpadding='0' cellspacing='0'>";
308 $data .= "<tr>";
309 $data .= "<td style='width: 50%;'>First Name: </td><td>".esc_html($wc_shipping_first_name)."</td>";
310 $data .= "</tr>";
311 $data .= "<tr>";
312 $data .= "<td style='width: 50%;'>Last Name: </td><td>".esc_html($wc_shipping_last_name)."</td>";
313 $data .= "</tr>";
314 $data .= "<tr>";
315 $data .= "<td style='width: 50%;'>Company: </td><td>".esc_html($wc_shipping_company)."</td>";
316 $data .= "</tr>";
317 $data .= "<tr>";
318 $data .= "<td style='width: 50%;'>Address Line 1: </td><td>".esc_html($wc_shipping_address_1)."</td>";
319 $data .= "</tr>";
320 $data .= "<tr>";
321 $data .= "<td style='width: 50%;'>Address Line 2: </td><td>".esc_html($wc_shipping_address_2)."</td>";
322 $data .= "</tr>";
323 $data .= "<tr>";
324 $data .= "<td style='width: 50%;'>City: </td><td>".esc_html($wc_shipping_city)."</td>";
325 $data .= "</tr>";
326 $data .= "<tr>";
327 $data .= "<td style='width: 50%;'>Zipcode: </td><td>".esc_html($wc_shipping_postcode)."</td>";
328 $data .= "</tr>";
329 $data .= "<tr>";
330 $data .= "<td style='width: 50%;'>Country: </td><td>".esc_html($wc_shipping_country)."</td>";
331 $data .= "</tr>";
332 $data .= "<tr>";
333 $data .= "<td style='width: 50%;'>State: </td><td>".esc_html($wc_shipping_state)."</td>";
334 $data .= "</tr>";
335 $data .= "<tr>";
336 $data .= "<td style='width: 50%;'>Email Address: </td><td>".esc_html($wc_shipping_email)."</td>";
337 $data .= "</tr>";
338 $data .= "<tr>";
339 $data .= "<td style='width: 50%;'>Phone: </td><td>".esc_html($wc_shipping_phone)."</td>";
340 $data .= "</tr>";
341 $data .= "</table>";
342
343 $data .= '</span></td></tr>';
344 }
345 }
346
347 break;
348
349 case 'two_way_login_phone':
350 include_once( $this->admin_path . 'includes/plugin.php' );
351 $twilio_option = get_option("pie_register_twilio");
352 $plugin_status = get_option('piereg_api_manager_addon_Twilio_activated');
353 if( is_plugin_active("pie-register-twilio/pie-register-twilio.php") && isset($twilio_option["enable_twilio"]) && $twilio_option["enable_twilio"] == 1 && $plugin_status == "Activated" ){
354 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
355 $data .= '</td><td class="fields"><span>'.esc_html($this->getValue($this->type, $this->slug)).'</span></td></tr>';
356 }
357 break;
358 case 'text' :
359 case 'textarea':
360 case 'dropdown':
361 case 'multiselect':
362 case 'number':
363 case 'radio':
364 case 'checkbox':
365 case 'custom_role':
366 case 'time':
367 case 'phone':
368 case 'date':
369 case 'list':
370 case 'invitation':
371 case "default":
372 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
373 $data .= '</td><td class="fields"><span>'.wp_kses_post($this->getValue()).'</span></td></tr>';
374 break;
375 case 'sectionbreak':
376 $class = "sectionBreak";
377
378 $data .= '<tr class="section-profile">';
379 if($this->field['label'] != ''){
380 $class .= ' break-label';
381 }
382 $data .= '<td class="fields fields2 '.esc_attr($class).'">';
383 $data .= wp_kses_post($this->addLabel());
384 $data .= '</td>';
385 $data .= '<td class="fields">';
386 $data .= '</td>';
387 $data .= '</tr>';
388 break;
389 case 'terms':
390 $data .= '<tr><td class="fields fields2">'.wp_kses_post($this->addLabel());
391 $data .= '</td><td class="fields"><span class="pr-profile-terms">';
392 $data .= '<input disabled'. checked($this->getValue() == '1', true, false) .' type="checkbox" value="1" >';
393 $page_id = $this->field['cont'];
394 $page_url = get_the_permalink($page_id);
395
396 // translators: %s is replaced by the URL link to view
397 $data .= apply_filters('piereg_terms_field_text',sprintf(__('Click <a target="_blank" href="%s">here</a> to view.','pie-register'),$page_url));
398 $data .= '</span></td></tr>';
399
400 break;
401 endswitch;
402 }
403 }
404 $data = apply_filters('piereg_filter_profile_front_table',$data);
405 $data .= '</table>';
406 }
407 else
408 {
409 $pie_pricing = get_user_meta($this->user_id,'pie_pricing',true);
410
411 if ( $pie_pricing == 'PaypalStandard' )
412 {
413 $payment_grid = apply_filters('piereg_display_recurring_paypal_payments_grid',"");
414 $data .= $payment_grid;
415 }
416 else
417 {
418 $payment_grid = apply_filters('piereg_display_recurring_stripe_payments_grid',"");
419 $data .= $payment_grid;
420 }
421 }
422 $data .= '</div>';
423 }
424 return $data;
425 }
426
427 }