Have an account? Sign in
Login  Register  Facebook
how to add more fields in user profile form of wordpress?
How can i edit the profile area or registration form of wordpressso that i can add some addtitional fields from user.???


also like to know if there is any pluggin in wordpress which allows to export user details from admin section.
Started: September 21, 2011 Latest Activity: June 25, 2015 wordpress
2 Answers
Process is nicely explained but doing so via code may be complicated for people not familiar with coding . Usually people customize their WordPress site and its fields to get better performance but unfortunately, they could not due to lack of understanding. Well, here is a fantastic article that may help you out in learning the entire process. Just go through it and give your feedback too.

See: http://wordpressdevelopmentservices.kinja.com/how-to-customize-wordpress-to-increase-performance-1708387842.

Posted: ChadGarza
In: June 25, 2015

With the following code, you can add some extra fields asking your members for their address. Just add the code t your theme’s functions.php file, or create a functions.php file if you don’t already have one.
<?php
add_action( \'show_user_profile\', \'extra_user_profile_fields\' );
add_action( \'edit_user_profile\', \'extra_user_profile_fields\' );
 
function extra_user_profile_fields( $user ) { ?>
<h3>
    <?php _e(\"Extra profile information\", \"blank\"); ?>
</h3>
 
<table class=\"form-table\">
<tr>
<th><label for=\"address\"><?php _e(\"Address\"); ?></label></th>
<td>
<input type=\"text\" name=\"address\" id=\"address\" value=\"<?php
    echo esc_attr( get_the_author_meta( \'address\', $user->ID ) ); 
?>\" class=\"regular-text\" /><br />
<span class=\"description\"><?php _e(\"Please enter your address.\"); ?></span>
</td>
</tr>
<tr>
<th><label for=\"city\"><?php _e(\"City\"); ?></label></th>
<td>
<input type=\"text\" name=\"city\" id=\"city\" value=\"<?php 
echo esc_attr( get_the_author_meta( \'city\', $user->ID ) ); 
?>\" class=\"regular-text\" /><br />
<span class=\"description\"><?php _e(\"Please enter your city.\"); ?></span>
</td>
</tr>
<tr>
<th><label for=\"province\"><?php _e(\"Province\"); ?></label></th>
<td>
<input type=\"text\" name=\"province\" id=\"province\" value=\"<?php
 echo esc_attr( get_the_author_meta( \'province\', $user->ID ) );
 ?>\" class=\"regular-text\" /><br />
<span class=\"description\"><?php _e(\"Please enter your province.\"); ?></span>
</td>
</tr>
<tr>
<th><label for=\"postalcode\"><?php _e(\"Postal Code\"); ?></label></th>
<td>
<input type=\"text\" name=\"postalcode\" id=\"postalcode\" value=\"<?php 
    echo esc_attr( get_the_author_meta( \'postalcode\', $user->ID ) ); 
?>\" class=\"regular-text\" /><br />
<span class=\"description\"><?php _e(\"Please enter your postal code.\"); ?></span>
</td>
</tr>
</table>
<?php }
 
add_action( \'personal_options_update\', \'save_extra_user_profile_fields\' );
add_action( \'edit_user_profile_update\', \'save_extra_user_profile_fields\' );
 
function save_extra_user_profile_fields( $user_id ) {
 
if ( !current_user_can( \'edit_user\', $user_id ) ) { return false; }
 
update_usermeta( $user_id, \'address\', $_POST[\'address\'] );
update_usermeta( $user_id, \'city\', $_POST[\'city\'] );
update_usermeta( $user_id, \'province\', $_POST[\'province\'] );
update_usermeta( $user_id, \'postalcode\', $_POST[\'postalcode\'] );
}
?>

Posted: MacOS
In: September 21, 2011

will it also save the data to database??
September 21, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer