Skip to content
wp-skills
Register
tools/wordpress-user-role-generator

WordPress User Role Generator

The WordPress user role generator allows you to generate a custom user role for your WordPress website.

Not add_role: that is the core function this calls, and a callback of the same name is a fatal redeclaration.

The key stored on the user and checked by current_user_can(). Lower case with underscores; it cannot be changed later without a migration.

What the Users screen shows. add_role() does not translate it, so this string appears as typed.

Capabilities

Super Admin

Admin

Editor

Author

Contributor

Subscriber

Custom capabilities1
  • #1
snippet.php
function register_user_role() {
	add_role(
		'author',
		'Author',
		array(
			// Pick capabilities above, or add them here.
		)
	);
}
// add_role() returns early when the role already exists, so running this on
// every request is harmless. register_activation_hook() is the better home for
// it if this snippet lives in a plugin.
add_action( 'init', 'register_user_role' );