You can use the WP_User class and the has_cap($role) method. The show_user_profile action passes a WP_User object as a parameter to the called function.
http://codex.wordpress.org/Class_Reference/WP_User#has_cap.28.24cap.29
add_action('show_user_profile', 'my_add_extra_profile_fields');
function my_add_extra_profile_fields($user) {
if ($user->has_cap('subscriber'))
{
//Code here
}
}
Related Posts:
- Saving custom profile fields
- How to show a gloabl message on a user profile page (in back end)?
- Is it safe to store a user setting you don’t want the user to ever modify as a user option?
- Extra profile field as select box?
- User Profile / Add Custom Fields
- How to reload the role specific registration form on validation errors?
- Add description text under input field for new profile fields
- BuddyPress – Hook to Update Custom Profile Fields [closed]
- Calling custom profile fields?
- Register rest field for specific user
- Buddypress Add unserialized Profile Fields in Members Loop [closed]
- WordPress User Profile Upload – If page is saved file reset
- How to add field above password section in profile page
- Add conditional custom option to ‘Display name publicly as’ dropdown
- Excluding Specific Fields from Profile Builder Registration Form
- Custom Profile Fields move from BBpress to BuddyPress
- Add additional ‘description’ field for defined roles / role metadata?
- Custom Field to a Role?
- Can’t save custom field on registration page
- Show image if author meta (profile fields) exists outside loop
- How to disable Edit Post and Allow only Custom Field?
- How can I create a profile field group that the user can’t see?
- HM CMB: Role Select
- How to parse a huge list of users using a CRON function?
- Display the output from Custom User Fields from a WordPress user profile on a WordPress Custom Page
- How to save multiple custom user profile fields using repeater JQuery
- Hide custom fields by user’s role
- want to add video upload option for front end user
- update_user_meta(): invisible data storage
- Register author, facebook connect, publish posts from front end
- Calling a custom profile field only it it exists
- how to add radio field on user meta on function.php?
- file upload user profile
- Custom post type needs to capability to create and edit by some specific user role
- Underscores in custom fields
- Add custom field to the archive page?
- Show only posts which can be commented OR have custom meta field
- Need small coding with Custom Fields Search
- get_post_meta() unserialize issue – returns boolean(false)
- How can I remove fields in the attachment editor?
- Unable to get Preview of Uploaded image within a Custom Meta box
- Edit Custom Database Tables in WordPress
- How to store the value of a custom field dropdown select for post referencing?
- Change content before writing to database
- post meta data clearing on autosave
- WordPress Search Custom Meta Field Only
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- Echo values from custom field outside loop php
- How to add content at the end of posts?
- Transfer self made functions.php custom fields to Advanced Custom Fields [closed]
- Complex WP_User_Query call fails on production server
- wordpress custom fields multiple data
- How do I define post titles as images using Custom Fields?
- How to show Small Box Inside Content Area, which holds (text, images, links)?
- Sort custom field by post
- Why the pagination for a query modified by pre_get_posts doesn’t mind the number & order of posts sorted & selected based on a custom date time field
- Trying to update_post_meta function
- How do i add custom fields to my themes template file?
- Select multiple images from custom field
- Ordering posts by custom field named “date” in backend
- How to pass page as an argument like post in WordPress?
- How to display custom fields from a plugin
- Adding “meta” info to WP site PHP function?
- WordPress Media Uploader custom Javascript not working
- Custom fields issue [closed]
- Select custom posts by meta_value and sort by a different meta value
- List custom queried terms in the edit-tags.php?taxonomy page
- Front end register with custom fields
- Display custom field from the front page on another page
- Display custom widget value in header.php
- Gravity Forms Update post meta from template [closed]
- Automatic linking terms
- Adding extra fields to front end signup form
- Problem uploading different files as custom fields with front end post form
- How to change order of posts in admin
- wpdb function insert doesn’t work
- make a dropdown custom field with ‘cities’ list in it
- How can I modify my meta_query to work with prices that are stored in the database that contain dollar signs and commas?
- Get Custom Field Name ( Label or Key ) Not Value
- Custom field on Quick Edit using select/dropdown – almost working right but not showing currently selected value
- Adding Custom Metadata to my Archive/Posts page
- Move the post title to another field
- Ordering by ACF custom field vaule
- add different custom fields value to post class if permalink or index
- author.php not showing content if Author has no Posts
- Create Shortcode shows only posts with custom_field meta
- Login_form add to top of form rather then bottom
- Advanced Custom Fields from Category – IF statement
- Get a different meta value with ajax when different elements are clicked
- Delete custom fields on post publish?
- How do you turn a custom field’s value into a permalink for that post?
- Permalink structure depending on custom field
- How to add custom_fields value in JSON API using create_post
- Using Hooks. Thematic
- WP Post Meta Box Field Not Showing Updated Field
- Parse Shortcodes in Theme’s Custom Field?
- Update field name without losing the value
- How do delete a meta key?
- Is there a way to read JSON data inside Custom Fields without editing PHP? [closed]
- Modal pop-up HTML code works on other sites or HTML viewers but not in the custom HTML block within a wordpress page?