I have the following code:
<input class="mt upbb" type="text" name="your_name" id="your_name" value="<?php echo info_username_get_meta( 'your_name' ); ?>">
How can I add a default text to that if the value is empty? Thanks in advance!
I have the following code:
<input class="mt upbb" type="text" name="your_name" id="your_name" value="<?php echo info_username_get_meta( 'your_name' ); ?>">
How can I add a default text to that if the value is empty? Thanks in advance!
You can always use a ternary operator if you want to do things inline:
value="<?php echo (!empty(info_username_get_meta( 'your_name' )) ? info_username_get_meta( 'your_name' ) : 'DEFAULT NAME' ; ?>"
Or break it out and assign the name in the code above:
<?php
$name = (!empty(info_username_get_meta( 'your_name' )) ? info_username_get_meta( 'your_name' ) : 'DEFAULT NAME';
?>
<input class="mt upbb" type="text" name="your_name" id="your_name" value="<?php echo $name; ?>">