I believe you can solve this by adding this PHP code snippet to your site:
add_action('wp_head', function(){
?>
<script>
jQuery(document).ready(function(){
jQuery('input[name="b2bking_subaccounts_new_account_name"], input[name="b2bking_subaccounts_new_account_last_name"]').prop('readonly', true);
jQuery('input[name="b2bking_subaccounts_new_account_name"], input[name="b2bking_subaccounts_new_account_last_name"]').attr('placeholder', 'This field can only be edited by the site admin');
jQuery('input[name="b2bking_subaccounts_new_account_name"], input[name="b2bking_subaccounts_new_account_last_name"]').css('background', '#d2d2d2');
});
</script>
<?php
});
Hi, I want to set input textboxes in New Subaccount to read-only. This means users cannot enter or paste text to these textboxes.
Can you please provide the custom CSS code to do this.
Thank you.
Attached files: Untitled656565.jpg
Hi Min,
Just to make sure I understand this correctly, can you please clarify, should it be for both "new subaccount" and "edit subaccount"?
So is the idea that only the website admin should be able to set the information there?
Please let me know and I'll work on a way to set that to read-only.
Kind regards,
Stefan
Hi Stefan,
I need them to be read-only on both "new subaccount" and "edit subaccount" pages.
Due to our business process, Last Name and First Name of subaccounts are only edited by WordPress admin.
So, CSS or code snippets would be suitable.
Thanks.
Thank you for clarifying,
I believe you can solve this by adding this PHP code snippet to your site:
A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/
It should result in those 2 fields being read-only:
The code also changes the text and the background color of the fields.
Kind regards,
Stefan
Thank you so much, Stefan!