This filter needs to return something. Try this
function modify_contact_methods($profile_fields) {
if(current_user_can('edit_users')) {
// Field addition and removal will be done here
// Add new fields
$profile_fields['company_name'] = 'Company Name';
$profile_fields['company_id'] = 'Company ID';
}
return $profile_fields;
}
add_filter('user_contactmethods', 'modify_contact_methods');
Related Posts:
- how to add custom user capabilities using add_user_meta or something else?
- Why does user_can return false for a capability during plugin deactivation?
- Is there way to rename user role name without plugin?
- How to create a clone role in wordpress
- How to add a Capability to a User Role?
- How can I get a list of users by their role?
- How do I make a draft post accessible to everyone?
- Reset default roles and capabilities
- What do unfiltered_html and unfiltered_upload actually filter?
- Temporary capability for current_user_can()
- Create custom user role (client) that can create another custom user role (employee) of that client
- Allow roles below admin to add subscribers only
- Temporarily give ‘manage_options’ capability
- Hide specific admin users’ posts
- Allow authors to edit only certain users
- How to update role capabilities
- How to loop through each user id?
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- Do custom user roles have any default capabilities?
- Ordering users of a specific role by last name
- How to programmatically add a user to a role?
- Shold I manually add ‘cap’ to admin role ?
- Allow users to publish child pages of the pages they have access to edit
- New Roles and Capabilities in WordPress
- Why is wp-login redirecting to the home page when I use this function?
- Allow contributor to view own scheduled post
- How to prevent users with “edit_others_posts” capability from editing admin posts
- How to get all users with Author role capabilities?
- How to check if a role has a specific capability
- Locking Down WordPress Application Password Permissions / Capabilities
- Prevent custom user role to add new pages
- Let new user role to ‘edit_others_posts’ of other user role, not of its own type
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- The delete_posts capability?
- Capabilites not working [closed]
- WordPress missing user roles on local dev machine. Live site works fine
- Remove wordpress author’s capability to moderate comments on their own posts
- Prevent Editors from Editing/Deleting Admin Accounts
- Assign second role to user
- Are User Levels Still Currently Used?
- Adding Capabilities to a WordPress User Account
- Adding an additional role to an Administrator
- Ability to only view (not edit) other user’s personal profile information
- Pending status by default for a specific role
- How do I restrict user access to plugins?
- Parent User and Child User – relate users
- My subscriber has the “edit comment” capability but can’t edit comment
- Show metabox for a special role
- Restrict Access to Posts based on Custom User and Post Meta Data
- Assign a role to the user who registers on a form
- User Role Capabilities for WordPress Gutenberg Blocks
- bbPress plugin moderator roles
- How to create user specific pages (not user role!)?
- Allowing user to edit posts based on the post status
- Custom capabilities to add, edit, remove users of a particular role only?
- How to change user role using hook
- Stop users of author role from editing already pending posts
- add_role user capability not working
- Purpose of Adding Capability to Role But Not Grant?
- How can I promote a user to a network administrator?
- Check role of Username then echo something if administrator [closed]
- How to get a users list by who created them?
- Custom wordpress admin page/url “You do not have sufficient permissions to access this page.”
- Hiding custom theme functionality using capabilities
- user_can() not working for comment authors
- How to write conditions based on user capabilities not on user role?
- What Capability is required to let a role RUN code in Edit Theme?
- Want to know parameters that can be passed to user_can() for access control by user capabilities
- WordPress add_rewrite_rule redirection match GET variable not passing through to custom template
- Can I Create a Second Admin Level User Role?
- Create sub-administrator role that can do everything except use or see the code editor
- Show global Message in User Profiles with admin only Input field in WordPress Backend
- Let editors view post in admin but not be able to perform a save/edit
- Capabilities don’t add
- Assigning multiple or additional capabilities to specific users or how to create additional roles like bbpress roles?
- how do I add role and capability after I create a new user
- Require Capability to View Woocommerce Product
- User role editor – Add download files capability
- Why can my subscribers create new posts for review?
- Disabled delete_others_posts if post is from admin
- How can I check if a visitor can read a post?
- How to query users to count all with a custom capability and limit it to a set of roles?
- Adding all custom capabilities to admin
- Change auth_cookie_expiration for specific roles and specific login times
- current_user_can( ‘edit_user’ ) does not work
- How to restrict subscriber editing other posts but read specific posts in backend
- Saving user meta “member_id” based on user role
- Create role that can edit some user details, but not the role
- Role and Capabilities: How do I allow user role to access theme options without enabling ‘manage_options’?
- Custom Gutenberg Block and unfiltered_html capability
- Best practices to handle multilpe roles and capabilities?
- Enable plugins for a specific user role
- Check what capabilitie(s) an action requires
- Force “submit for review” on update?
- Users can only save their draft once before saving for revision
- Need to create admin user without capability to create user
- How do I make a draft post accessible to everyone?
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- update_user_meta on registration but only for default role type
- Grant access to admin menu?