first about the add_role
you only need to run this once, so after you paste it in your functions.php and saved
you can remove it and save again and the role will be there always.
then about the author_can function, i really never use it so i can tell whats wrong but you can use current_user_can() function like this:
update
if ( is_user_logged_in() ) {
//first you get the curent user info
get_currentuserinfo();
//then you can check capabilities like this
if(current_user_can('display_map')){
echo '<li><a href="#map">Map</a></li>';
}
}
hope this helps
Related Posts:
- What action should I hook into when adding roles and capabilities?
- What’s the difference between Role and Meta capabilities; When to use map_meta_cap() filter
- Disable posts, only allow to edit existing pages, not create new ones (create_posts)
- How to get all capabilities of an existing user role
- Does the “promote_users” capability allow someone to create a new admin account?
- Add Media Upload Capabilities Needed for Custom Role for non-Posts
- How can I prevent a writer from being able to edit an article that has been scheduled?
- Check whether user can delete a given post
- Allow unfiltered HTML in titles for low level users?
- Allow users to set a post author
- Unify the roles and caps?
- Filter list of rules based on a capability
- How to show a admin bar menu item only to users with certain capabilities?
- Theme option editing capability problems
- Assign multiple roles , overlapping capabilities
- WordPress remove capability post ,media completely for custom role
- Add capability to a role , so user is only able to view his own posts
- Is there a way of retrieving the core WP capabilities?
- Best Roles and Capability on a site with review features using a front end custom post
- Manage Roles and Capabilities on Multi-site
- Is there way to rename user role name without plugin?
- Possible to hide Custom Post Type UI/Menu from specific User Roles?
- How to add a Capability to a User Role?
- How can I get a list of users by their role?
- Remove Ability for Other Users to View Administrator in User List?
- Reset default roles and capabilities
- WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins
- Allow Editors to edit pending posts but not draft ones
- How to let contributors to create a new revision(draft) editing their published posts
- How to assign specific users the capability to edit specific pages / posts / custom post types
- Defining capabilities for custom post type
- Temporarily give ‘manage_options’ capability
- Hide specific admin users’ posts
- \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
- Allowing Custom Capability to Manage Plugin Options
- Create user role restricted to specific CPT
- How to set individual capabilities on a taxonomy? Or how to re-register an existing taxonomy?
- Prevent user creating new users with specific roles
- Add Capabilities to Custom Post Type after it has been created [duplicate]
- How-to Delay The Capability To Publish Posts?
- Shold I manually add ‘cap’ to admin role ?
- Why is wp-login redirecting to the home page when I use this function?
- Allow contributor to view own scheduled post
- Capability for allowing user to post own comments without moderation
- Prevent custom user role to add new pages
- User role permissions based on taxonomies
- The delete_posts capability?
- Capabilites not working [closed]
- Allow Administrator role access to custom capabilities [duplicate]
- Get User Role by ID not working
- Remove menu items from admin page and limit capabilities
- Why is my Custom Post Type not showing up after adding capabilities?
- Adding an additional role to an Administrator
- current_user_can() return FALSE but debugging says TRUE
- Ability to only view (not edit) other user’s personal profile information
- map_meta_cap woes
- Roles for Custom Post Types
- can’t see custom post content filtered under “mine” filter in admin panel
- My subscriber has the “edit comment” capability but can’t edit comment
- Giving permission to anyone (non-users as well) with a password to edit a post, possible?
- “Submit for review” for updates on existing posts
- Add a role and give admin priviledges
- “edit_published_posts” and “edit_other_post” issue
- Adding post tags without capability edit_posts
- Custom Capabilities for CPT and Problem with current_user_can()
- Custom wordpress admin page/url “You do not have sufficient permissions to access this page.”
- user_can() not working for comment authors
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- Select other roles as custom post authors
- How to get all capabilities
- User Capabilities are not available in WP REST permission callback?
- current_user_can(‘administrator’) not working in custom login
- Redirect admin 403 “Cheatin uh?” admin pages
- Let editors view post in admin but not be able to perform a save/edit
- Capabilities don’t add
- Remove specific administrator’s capability
- how to change capability required to view an admin page? [duplicate]
- How to determine which capability to use?
- Edit and delete permissions pages and posts
- Allow a user or role to view drafts and previews, but not other admin privileges?
- Adding all custom capabilities to admin
- See which user role / capability is needed to use a plugin
- How to give plugin access to specific role(s)
- current_user_can( ‘edit_user’ ) does not work
- How to restrict subscriber editing other posts but read specific posts in backend
- Allowing custom role user to edit post assigned to them but don’t let them create new custom type post
- Custom roles and capabilities media not work right
- Best practices to handle multilpe roles and capabilities?
- Buddy Press restrict the capability to edit users
- Not allow add New Page for role ‘editor’
- Check what capabilitie(s) an action requires
- Force “submit for review” on update?
- Prevent author role from editing others posts
- How do I make a draft post accessible to everyone?
- Can’t create new Pods pages
- Pricing Tables admin page capability
- Not able to give editors acess to new admin menu item
- Read-Only custom post type
- current_user_can() returning true for capability when the user and role do not have the capability
- Can I remove WooCommerce specific product categories from shop managers?