Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Default input values WordPress

  • SOLVED

How to add into these fields...

(1) if($CampRow->camp_field_full_name == 1 ){
$output .='<p class="donation_fullname"><label for="fullname">'.__('Full Name').':</label><input type="text" name="full_name" id="full_name" /></p>';
} - <strong>BP full name</strong>
(2) if($CampRow->camp_field_email == 1 ){
$output .='<p class="donation_email"><label for="email">'.__('Email').':</label><input type="text" name="email" id="email" value="" /></p>';
} - <strong>WP user email</strong>

...as their default values?
Thanks.

Answers (3)

2011-06-19

Daryl Lozupone answers:

Dmitriy--


for BP user fullname:


global $bp;

$output .='<p class="donation_fullname"><label for="fullname">'.__('Full Name').':</label><input type="text" name="full_name" id="full_name" value="' . $bp->loggedin_user->fullname . '"/></p>';



for WP user email:


global $current_user;
get_currentuserinfo();

$output .='<p class="donation_email"><label for="email">'.__('Email').':</label><input type="text" name="email" id="email" value="' . $current_user->user_email . '" /></p>';


Hope that helps.

--Daryl Lozupone


Dmitriy Son comments:

Hi, Daryl!
It doesnt' work.
Instead of full name d email i see 'bp_user_fullname' and nothing.


Daryl Lozupone comments:

I updated my answer. It should work now!


Dmitriy Son comments:

Thanks!!

2011-06-19

Julio Potier answers:

Hello

Fill the "value" properties ?!

2011-06-19

Fahad Murtaza answers:

Hi Dimitry

I had solved half of your problem last time, and I will soon release my full fledged plugin with your requested features. Anyhow, solution to this question is easy


if($CampRow->camp_field_full_name <>'' ){ // checks if field is not empty
$output .='<p class="donation_fullname"><label for="fullname">'.__('Full Name').':</label><input type="text" name="full_name" id="full_name" value="'.$CampRow->camp_field_full_name.'" /></p>';
}




if($CampRow->camp_field_email <>'' ){ // checks if field is not empty
$output .='<p class="donation_email"><label for="email">'.__('Email').':</label><input type="text" name="email" id="email" value="'.$CampRow->camp_field_email .'" /></p>';
}


Let me know if it answers your question. It checks if the value is not empty and then inserts the same value into text field's value element.










Fahad Murtaza comments:

A bit more explanation of the problem will help though.


Dmitriy Son comments:

Hi, Fahd!
I'll reply to your pm a bit later, ok?
Daryl is closer to an answer.