Managing Roles and Capabilities for Your Sports WordPress Site

SportsPress adds new roles and capabilities to WordPress so you control what your users can do. Want to enlist some help managing your website? Done! Want to give coaches the option to edit their profiles? Done! You can adjust just how much access to give everyone.

A user role in WordPress is a type of account that has certain permissions attached to it. An admin user role, for example, has access to everything on a website, while a subscriber has very limited access. WordPress capabilities are the specific set of actions that are applied to user roles.

For your sports site, you can have access to everything as an admin, but you can also adjust other users’ roles based on what you need them to be able to do within your site. That way, you can give access where its needed to certain members, but not everyone.

With SportsPress, you have the option to manually create accounts and set each individual user’s role on your sports website. You can also enable account registrations and set a role for users to automatically take on when they create an account. You can also edit each role to include a custom set of permissions.

Here are more details on WordPress and SportsPress roles and capabilities, why they’re useful, how to manually or automatically set a user role and how to customize SportsPress roles with different capabilities with code.

WordPress Roles and Capabilities

In WordPress, capabilities are actions that can be applied to a website. Capabilities include the ability to edit posts, create pages or categories, and manage parts of the website such as plugins, themes and other users. But they don’t stop there. There’s a capability for just about anything you want to do in WordPress.

Capabilities are also coded into the WordPress platform and are assigned to user roles, which are different account levels. Each role has certain capabilities attached to it based on the level of access needed to the WordPress website.

For example, the administrator user role is meant for the person who is set to manage an entire single installation. Typically, this is the owner or developer who created the site. The admin role has the highest number of assigned capabilities and has access to everything on a WordPress site.

The only exception is if the Multisite feature is enabled and multiple websites can be created using one WordPress installation. In this case, the user role with the most assigned capabilities is the super admin. This user role has access to everything on each site in the network.

An editor is the user role with the second highest amount of assigned capabilities. An account with this user role can edit posts other users or themselves make, but access isn’t granted to everything.

Skipping down to the last user role is a subscriber which only has capabilities to manage the account’s own profile.

For details, check out Roles and Capabilities in the WordPress Codex.

What’s Roles and Capabilities Got to Do with It?

Roles and capabilities help control what user access in order to prevent unwanted changes from being applied to a website. At the same time, users who need access to manage certain parts of the site can do so freely.

As previously mentioned, there are new roles and capabilities available after installing SportsPress. They’re different than the default ones for WordPress.

SportsPress Roles and Capabilities

These new SportesPress roles and capabilities are created to help you better manage your sports WordPress website:

  • Leaugue Manager – Similar to the WordPress admin, this user role has access to everything.
  • Team Manager – This user role can publish, edit and delete players, staff, events, player lists, and posts. Users can also edit or submit assigned teams for review.
  • Event Manager – Users with this role can publish, edit and delete events. They can also edit or submit assigned players, staff, teams, and post for review.
  • Staff – Staff members can edit or submit assigned staff, events, teams and posts for review.
  • Player – Players can edit or submit assigned players, events, teams and posts for review.

To better illustrate what each SportsPress user role has access to, check out the table below.

League Manager Team Manager Event Manager Staff Player
Calendars Full access
Leaugue Tables Full access
Sponsors Full access Edit and submit what’s assigned for review
Staff Directories Full access Full access
Player Lists Full access Full access
Staff Full access Full access Edit and submit what’s assigned for review Edit and submit what’s assigned for review
Teams Full access Edit and submit what’s assigned for review Edit and submit what’s assigned for review Edit and submit what’s assigned for review Edit and submit what’s assigned for review
Players Full access Full access Edit and submit what’s assigned for review Edit and submit what’s assigned for review Edit and submit what’s assigned for review
Events Full access Full access Full access Edit and submit what’s assigned for review Edit and submit what’s assigned for review

For details on SportsPress roles and capabilities, check out the plugin’s Summary of Roles and List of Capabilities documentation pages.

Before Getting Started

It’s best practice to create a full backup of your WordPress website before making any changes. That way, if something goes wrong with the adjustments you made, you can roll back to the previous, unaffected version of your site.

This is especially true if you plan to customize the SportsPress user roles, which is covered later on.

It’s also important to consider who exactly you’re entrusting to certain user roles you set for them as the admin. It’s important you only give access to those you trust since they can change certain aspects of your sports website.

It’s best to give only the access that’s necessary for a user to complete necessary tasks rather than having them have access to everything. This prevents hackers from being able to also have access to most or all of your site if they’re able to hack into one of your site’s user accounts.

When you’re ready, you can go ahead, and install and activate SportsPress. If you prefer to have access to all of SportsPress’s features, you can install SportsPress Pro instead.

Once that’s done, set up the plugin manually or by using the installation wizard. You can check out How to Build a Baseball Website with WordPress and SportsPress and Making a Slam-Dunk Tournament WordPress Site with SportsPress Pro for details.

Manually Creating a User and Setting a Role

You can manually set a user role for an account once you create it. You can also set a user role to be automatically assigned to new account sign-ups. This is covered later on.

Creating an Account

To create a new user account, go to your admin dashboard > Users > Add New.

Add a new user by filling out the Add New User section.

Under Add New User, enter a username for the account and the email address of the person for which you’re creating the account in the corresponding fields.

Choosing a User Role

Next, click on the Role drop down box and choose from one of the default or SportsPress user roles.

Select a user role from the Role drop down box.

When you have selected the role you want for the account, click the Add New User button.

At this point, an email will be sent to the one you entered and there will be a prompt to choose a password. If you don’t want the user to receive an email because you want to set a password yourself, for example, you can check the Skip Confirmation Email box before you click the button to create a new user.

Once the account has been created, the new user will have access to only the capabilities assigned to the user role you chose for them.

Be sure to include a login link somewhere on your sports website to ensure your new user can easily log in or otherwise provide them with login instructions.

You can add a link to your menu bar, to a widget or where ever else you want to add the link.

You can also use SportsPress to customize the login page with your logo and branding colors so it looks more familiar to your site’s members.

For details, check out Adding a Custom Link Menu Item, Adding Links in WordPress and How to Allow WordPress User Registration and Assign SportsPress Roles.

Allowing Site Registrations with a Set User Role

Rather than manually creating a new account for each person you want to grant access to your site, you can enable website registrations so accounts can be created by anyone. You can also set a user role for new signups using SportsPress.

To enable registrations for your sports website, go to Settings > General and check the Anyone can register box next to Membership.

Check the Membership box so anyone can register a user account.

Then, select one of the roles from the New User Default Role drop down box directly below the checkbox option.

Select a user role to use as the default for new registrations.

Next, scroll down to the bottom of the page and click the Save Changes button.

New users who register for an account on your site will be automatically assigned with the user role you just set.

Similar to manually setting a user role, be sure to include a link to the login page or otherwise let users know where they can log in so they can access your site and their account. You can also customize your site’s branding with SportsPress as mentioned earlier.

Customizing User Roles with Capabilities

Not only can you manually and automatically set SportsPress user roles, but you can also edit the user roles with code to include the specific capabilities you want.

This can be particularly useful if the default SportsPress user roles don’t work with the type of sports website you set up or the types of accounts you need to set up.

Basic Housekeeping

Keep in mind that if you edit the SportsPress files to edit roles, each update for the plugin will erase the changes you have made. To avoid this, it’s recommended that you create a separate plugin to apply the capabilities you want to your user roles.

You can check out Writing a Plugin and WordPress Essentials: How to Create a WordPress Plugin for details.

It may also be important to note that you should create a full backup of your website before making any adjustments as mentioned earlier.

Editing SportsPress User Roles

SportsPress user roles and capabilities are initialized during the installtion process of the plugin. It’s done through the create_roles() in the /sportspress/inclides/class-sp-install.php file.

For SportsPress Pro, it can be found in the /sportspress/includes/sportspress/includes/class-sp-install.php file.

This is the file you want to edit to adjust SportsPress user roles.

You can edit the file by downloading a copy, editing it with your preferred code editor, savit it and reuploading it to your site’s server. You can also edit the file directly using FTP with clients such as FileZilla or through SSH and the command line.

Locate the add_role() functions to find the user role you want to change.

For example, this is the code for Event Managers:


add_role(
'sp_event_manager',
__( 'Event Manager', 'sportspress' ),
array(
'level_1' => true,
'level_0' => true,

‘read’ => true,
‘delete_posts’ => true,
‘edit_posts’ => true,
‘upload_files’ => true,
‘manage_categories’ => true,

‘edit_sp_event’ => true,
‘read_sp_event’ => true,
‘delete_sp_event’ => true,
‘edit_sp_events’ => true,
‘edit_others_sp_events’ => true,
‘publish_sp_events’ => true,
‘delete_sp_events’ => true,
‘delete_published_sp_events’ => true,
‘edit_published_sp_events’ => true,
‘manage_sp_event_terms’ => true,
‘edit_sp_event_terms’ => true,
‘delete_sp_event_terms’ => true,
‘assign_sp_event_terms’ => true,

‘edit_sp_team’ => true,
‘read_sp_team’ => true,
‘edit_sp_teams’ => true,
‘edit_published_sp_teams’ => true,
‘assign_sp_team_terms’ => true,

‘edit_sp_player’ => true,
‘read_sp_player’ => true,
‘edit_sp_players’ => true,
‘edit_published_sp_players’ => true,
‘assign_sp_player_terms’ => true,

‘edit_sp_staff’ => true,
‘read_sp_staff’ => true,
‘edit_sp_staffs’ => true,
‘edit_published_sp_staffs’ => true,
‘assign_sp_staff_terms’ => true,
)
);

If you don’t want to include a capability that’s listed, you can change true to false.

You can also add a SportsPress capability with the same structure.

For a list of all the available SportsPress capabilities, check out Roles and Capabilities, and List of Capabilities.

Adding or Removing User Roles

You can also add your own user roles by following the same structure and by using the add_role() function. Conversely, you can remove existing user roles with the remove_role() fuction.

Be sure to make the edits to the /sportspress/inclides/class-sp-install.php file or the /sportspress/includes/sportspress/includes/class-sp-install.php file in SportsPress Pro.

For details, check out Function Reference/add role and Function Reference/remove role in the WordPress Codex.

Wrapping Up

Assigning and customizing user roles can be useful to your sports WordPress website. You can get assistance from others to help you run the site and only give them the level of access that they need. That way, uncessary or unwanted changes won’t be made without approval from the site admin.

SportsPress can make it happen with a few adjustments as outlined above. Plus, there are tons more features and user role capabilities available when you upgrade to SportsPress Pro.

How do you plan on using roles and capabilities for your sports WordPress website? What features would you like to see implemented in SportsPress? Did you run into troubles while making any of the adjustments above? Let us know on Twitter or Facebook.

Stay in the loop

Enjoy this article? Get more content like this directly in your inbox.

Take your club to the next level

Already have a theme? SportsPress Pro adds advanced sports features to any WordPress site, and works perfectly together with any of our themes.