Pre-populate fields in sign up form

How to pre-poplulate the fields with placeholder text in the Pro Site sign up form
<input type="text" name="fname" placeholder="First name">
<input type="text" name="lname" placeholder="Last name">

  • Lindeni Mahlalela

    Hello robertvideo

    I hope you are doing great today. Thank you for contacting us regarding this.

    I have looked into this and have prepared the following script which you can use an mu plugin or in your theme's functions.php, it should a placeholder attribute to the checkout fields in Pro Sites, you can customize the placeholder's to suite your needs. Basically, I think it is best to get the IDs of the input fields using the debug tool in your browser and then write some JavaScript code to add the placeholders dynamically without modifying the Pro Sites plugin, here is how I did it for the main checkout fields:

    add_action( 'wp_footer', 'enqueue_pre_populate_fields_scripts');
    public function enqueue_pre_populate_fields_scripts(){
    	if ( is_page("pro-site") ) : //replace "pro-site" with the slug of your pro-sites page if you renamed it
    		?>
    		<script type="text/javascript">
    			(function( $ ) {
    	 			"use strict";
    	 			$(function(){
    	 	 			$(document).ready( function(){
    	 	 				$('#user_name').attr('placeholder', 'Your preferred username');
    						                 $('#user_email').attr('placeholder', 'Email address');
    	   					        $('#blogname').attr('placeholder', 'yourname');
    	  					        $('#blog_title').attr('placeholder', 'Title of your website');
    	 	  				$('#cc_name').attr('placeholder', 'Your Name / Card Holder\'s name');
    	 					        $('#cc_number').attr('placeholder', '4242 4242 4242 4242'); //sample credit card number
    	 				});
    				});
    			}(jQuery));
    		</script>
    	<?php
    	endif;
    }

    You can place this code in your theme's functions.php file. I suggest you add it to a new file call it 'prepopulate-fields.php' then add the code as follows:

    <?php
    //all the code above

    Save it and upload it to your website in the folder 'wp-content/mu-plugins', alternatively you can download the attached zip file, extract/unzip it and upload the contained .php file to your 'wp-content/mu-plugins' folder.

    If you have extended the signup form with additional fields, you can add them to the script as well like this:

    $('#field_id').attr('placeholder', 'Your preferred username'); //add by id

    Or

    `$('input[name="input_name"]).attr('placeholder', 'Place Holder'); //add by name of input'

    I hope this helps, please let us know if you need any further assistance and we will be happy to help in any way possible.

    Have a nice day.
    Mahlamusa

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.