0
votes

I want to add extra fields in user profile with respect to user roles.

Actually I am creating a website on wordpress which requires to type of users Buyers and Sellers. And I have already created two custom roles 'Buyer' and 'Seller'.

Now I need some different fields for user with buyer role and some different fields for user with seller role.

1
No need to reinvent the wheel. WP has many great membership plugins. Have a look at s2member for example: s2member.com - Matanya
Really thanks for your reply. Okay let me check this whether it full fills my requirement or not. Anyhow still someone have any solution apart from plugin. Do let me know. - Noman
Plugins can be very bloated and aren't always the best solution. - user2019515
Yes that is why I want to know something other than plugin. Please share with me if you know any. - Noman

1 Answers

1
votes

Following are the resources that may help you achieving the required functionality

Adding fields when editing - but your custom fields will not come up if you are adding a user(for this its the next link) https://wordpress.stackexchange.com/questions/23813/adding-fields-to-the-add-new-user-screen-in-the-dashboard

Adding the custom fields when adding the new user from the CMS http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields

For showing the different fields based on role https://wordpress.stackexchange.com/questions/52547/different-fields-in-my-profile-page-depending-on-user-role

I guess the specified code in the above link might not work when you are adding the user from the cms you have to hook some javascript and hide and show your desired fields based on the role - use the following code to achive this.

 function hide_options(){
echo "\n" . '<script type="text/javascript">jQuery(document).ready(function($) {

);

function syncMailingAddress(){

    jQuery("#mailing-address").val(jQuery("#address").val());
    jQuery("#postaladdress").val(jQuery("#address").val());

}
</script>' . "\n";
}
add_action('admin_head','hide_options');