Skip to content

Commit 584d3dc

Browse files
committed
Prefill first name and last name for logged in Users.
1 parent b2911cf commit 584d3dc

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

public/class-paystack-forms-public.php

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -563,13 +563,19 @@ function kkd_pff_paystack_fetch_plan($code){
563563
}
564564
function kkd_pff_paystack_form_shortcode($atts) {
565565
ob_start();
566-
if ( is_user_logged_in() ) {
567-
$user_id = get_current_user_id();
568-
}else{
569-
$user_id = 0;
570-
}
571566

572-
extract(shortcode_atts(array(
567+
global $current_user;
568+
// wp_get_current_user();
569+
$user_id = $current_user->ID;
570+
$email = $current_user->user_email;
571+
$fname = $current_user->user_firstname;
572+
$lname = $current_user->user_lastname;
573+
if ($fname == '' && $lname == '') {
574+
$fullname = '';
575+
}else{
576+
$fullname = $fname.' '.$lname;
577+
}
578+
extract(shortcode_atts(array(
573579
'id' => 0,
574580
), $atts));
575581
if ($id != 0) {
@@ -600,13 +606,25 @@ function kkd_pff_paystack_form_shortcode($atts) {
600606
echo '<div class="span12 unit">
601607
<label class="label">Full Name <span>*</span></label>
602608
<div class="input">
603-
<input type="text" name="pf-fname" placeholder="First & Last Name" required>
609+
<input type="text" name="pf-fname" placeholder="First & Last Name" value="' . $fullname. '"
610+
';
611+
if($loggedin == 'yes'){
612+
echo 'readonly ';
613+
}
614+
615+
echo' required>
604616
</div>
605617
</div>';
606618
echo '<div class="span12 unit">
607619
<label class="label">Email <span>*</span></label>
608620
<div class="input">
609-
<input type="email" name="pf-pemail" placeholder="Email Address" id="pf-email" required>
621+
<input type="email" name="pf-pemail" placeholder="Enter Email Address" id="pf-email" value="' . $email. '"
622+
';
623+
if($loggedin == 'yes'){
624+
echo 'readonly ';
625+
}
626+
627+
echo' required>
610628
</div>
611629
</div>';
612630
echo '<div class="span12 unit">

public/css/pff-paystack-style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@
426426
.j-forms .input textarea:focus + .tooltip-right-bottom,
427427
.j-forms .select select:focus + .tooltip-right-bottom { left:auto; right:0; }
428428

429+
429430
.j-forms .tooltip-right-side { margin-left:8px; top:8px; white-space:nowrap; }
430431

431432
.j-forms .tooltip-right-side:before {
@@ -1774,3 +1775,6 @@
17741775

17751776
.j-forms .checkbox-block input:checked ~ .block-content .block-image-title,
17761777
.j-forms .radio-block input:checked ~ .block-content .block-image-title { background:rgba(0,0,0,.77); }
1778+
.j-forms .input input[readonly] {
1779+
cursor:not-allowed;
1780+
}

0 commit comments

Comments
 (0)