I am trying to get field_1
value into the input text and I tried this code but it doesn't work.
function bbg_add_reg_field() {
$field_1= $_POST["signup_username"];
echo '<input name="field_1" id="field_1" value="$field_1" type="text">';
}
add_action( 'bp_before_registration_submit_buttons', 'bbg_add_reg_field' );
The echo value shown inside the input text is $field_1
The value should be a name, say for example peter
.
In PHP you can interpolate a string (add variables to a string with $var) only when it is a double quoted string.
From the PHP Documentation
Instead you could do this
oh and don't forget htmlspecialchars
You could also achieve the same using PHP Heredoc. Which goes like this