Do not set header
in a template file. Those are part of the HTTP request itself.
About your problem:
Add a template (whatever file you need – see “Template Hierarchy”). On top of it you include the default stuff like get_header();
and so on. For the restricted part, you use the following:
if ( current_user_can( 'view_players_area' ) )
{
// Code that you want to show to logged in users
// with a capability of `view_players_area`
}
else
{
# @link http://queryposts.com/function/wp_login_form/
wp_login_form();
}
Related Posts:
- Add, edit specific CPT with custom role
- Explanation of User Roles and Capabilities
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- Disable posts, only allow to edit existing pages, not create new ones (create_posts)
- Authentication / login mechanism (non wp-admin)
- Is there a simple way to manage capabilities per user?
- Why is unfiltered html allowed in custom fields for author / contributor roles?
- How to check if a role has a specific capability
- Different Admin Theme – Based on Role?
- How to remove sticky post capability for a specific user role?
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- Remove wordpress author’s capability to moderate comments on their own posts
- Can you set a role as author?
- WordPress Local Install Theme Folder Permission To Edit
- Are User Levels Still Currently Used?
- Roles for Custom Post Types
- Applying roles to an admin sub-menu (eg Appearance -> Menus)
- What are the minimum role/permissions for freelance developer?
- Limit number of users a role can create
- Question regarding WP multisite feature
- How to change footer or for different kinds of users in wordpress?
- Hiding custom theme functionality using capabilities
- User Capabilities are not available in WP REST permission callback?
- If user is logged in and has a role echo statement
- How to hide plugin options for editors via functions.php
- Show only pages you are author of
- Why “Mine” is the default view when adding ‘capability_type’ in register_post_type
- See which user role / capability is needed to use a plugin
- Force “submit for review” on update?
- current_user_can() returning true for capability when the user and role do not have the capability
- How might I enable a user to view Draft pages from a different Author, without the ability to edit?
- How can I enforce user to use Application password to generate JWT token? [closed]
- What is the general function to add a Widget area (not of a particular type)?
- Custom page template not showing on page creation
- get currently showed author ID in theme functions.php
- Capibilities of CPT WordPress
- Groups roles & capabilities
- WordPress Post Order
- How can I remove “Add new” button on custom post type
- WordPress Custom font not found
- Code showing in wordpress post titles around website
- WordPress uploads do not show up and I see the white screen of death in some cases
- Why content is not adding for each blog post
- How do I control the header space in non-front pages in Twenty Seventeen?
- register_theme_directory() sees custom themes directory, but blank frontend
- Customizer Image-Picker Preview Not Working
- How to customize the colors within a stylesheet using a WordPress setting
- How can i create my Onepage smoothscrool WordPress theme?
- Target second from last post in loop
- Correct was to customise theme using get_theme_mod in scripts
- What is the best practice workflow for new website overhaul and keeping current SEO ranking? [closed]
- Two instances of the theme folder in the URL
- Why does user_can return false for a capability during plugin deactivation?
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Why user profile update creates Additional Capabilities
- I want to change the author name
- Does any JavaScript file load automatically for index.php file?
- A different role for each site in a multisite
- WordPress menu walker – Get parent item text inside end_lvl function
- Custom theme vs theme customization?
- How to hook into wordpress upgrade procedure for a custom theme
- Child theme in separate WordPress Install
- Second page of archive is empty
- Display problems in admin dashboard when creating a new theme from scratch
- How to achieve this navigation style in wordpress navigation
- Change header image on a particular page
- Capabilities and mapping required for a role to be able to edit other’s posts of a custom type, BUT only be able to edit their own blog posts
- Alter theme pages on language switch
- style.css not being rendered in browser
- How to hide blog by id wordpress multisite listing
- How to dowload and edit content of a website
- wp_kses allow checkbox class and checked
- Uncaught Reference error in Retina.js
- Make a custom field in admin post.php read only
- Is wp_mail plugin territory?
- how to add jquery to wordpress
- HTML TO WP Theme : Submenu goes down wp_nav_menu
- wordpress thumbnail onclick then modal will come out
- wp_editor some functionality not working on custom theme
- Update modified Shopify third-party theme [closed]
- Should I detect the device or the page first?
- Create settings field on button click
- WordPress install checking permissions of user id 0
- Change site title color on individual pages
- Can’t upload images on new theme
- Git ignore everything except custom theme directory
- How does mediaelement.js work in WordPress?
- How to load mediaelement.js in theme template?
- HTML to → WP Conversion
- Why the capability ‘activate_plugins’ is needed to allow a role to see all posts/pages/comments?
- Add multiple sections, settings and controls at once to the Customizer
- Font not loading [closed]
- Images use & location, on new wordpress theme
- how can I re-utilize and class on a child theme
- How to change parent permalink?
- hide/show a div in wordpress
- How to get url image page the right way?
- Mobile view logo background colour in wordpress
- How to fix an issue with customizer live preview?
- how to call options on front end and add logo