WP Security role

The Survival WordPress Plugin will be primarily used by referees and Team members. The team members want to know their position of the survivals. The referees need to able to update the Team scores. But referees as well as Team members are not allowed to create/delete/publish new posts.

This is where WordPress roles prove to be useful. In the activation part of the plugin include the add_role().

Then when the plugin is deactivated, we need to remove the role by calling remove_role().

See also: WordPress Role capabilities.

To ensure the security of a private page, allowing access only to users with the referee role (or higher), verify whether the user has been assigned the appropriate role.

Example helper method:

And to complete the security statements, you can use ‘is_user_logged_in‘ to check whether or not the user is logged in.

See also: in_array(), array_intersect(), wp_get_current_user() and wp_die()