php – Auto-fill logged user username in the input area (WordPress plugin)

Question

I am trying to auto-fill the username in the input area when a logged user accesses the page. The input area is generated with a WordPress plugin.

Here is the PHP code of the plugin for the input area.

'<label class="asp_product_custom_field_label">%s</label><input id="asp-custom-field" name="stripeCustomField" class="pure-input-1 asp_product_custom_field_input" type="text"%s placeholder="%s"%s>',esc_html( $field_name ),( $mandatory ? ' data-asp-custom-mandatory' : '' ),esc_attr( $field_descr ),( $mandatory ? ' required' : '' ));

I have tried added

<?php $current_user = wp_get_current_user(); ?>

Then edit the HTML code from the plugin. It’s just turned out not working and breaking my WordPress website.

<input id="asp-custom-field" name="'<?php echo $current_user->display_name; ?>" class="pure-input-1 asp_product_custom_field_input" type="text" data-asp-custom-mandatory="" placeholder="Hostboring.com account username" required="">

You may visit the link below for the live demo, Thanks for your help
https://hostboring.com/asp-products/vps-lite/
Demo Account
Username: demo
Password: demo

Input Area

0
Liang 2 weeks 2021-11-16T12:20:39-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse