Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/e125cebfed768d3d9b4c01a10da52402 to your computer and use it in GitHub Desktop.
Save kimwhite/e125cebfed768d3d9b4c01a10da52402 to your computer and use it in GitHub Desktop.
Adds a hint to the first and last name fields at checkout.
<?php // do not copy this line.
/**
* This recipe will let you add hints to default WordPress fields (also child sponsor fields)
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_default_fields_checkout_hints() {
?>
<script>
jQuery("#username").parent().append("<p><small class='lite'>I am a hint for username.</small></p>");
jQuery("#password").parent().append("<p><small class='lite'>I am a hint for password.</small></p>");
jQuery("#bemail").parent().append("<p><small class='lite'>I am a hint for email.</small></p>");
jQuery("#first_name").parent().append("<p><small class='lite'>I am a hint for first name.</small></p>");
jQuery("#last_name").parent().append("<p><small class='lite'>I am a hint for last name.</small></p>");
jQuery('input[name="add_sub_accounts_username[]"]').after("<p><small class='lite'>child username</small></p>");
jQuery('input[name="add_sub_accounts_email[]"]').after("<p><small class='lite'>child email</small></p>");
jQuery('input[name="add_sub_accounts_password[]"]').after("<p><small class='lite'>child password</small></p>");
</script>
<?php
}
add_action( 'pmpro_checkout_after_billing_fields', 'my_pmpro_default_fields_checkout_hints' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment