Is it possible to add a new subscriber role with a function, that has the same capabilities with the existing subscriber role within WordPress?
Basically I would like to distinguish between male and female subscribers based on the wordpress role.
Is it possible to add a new subscriber role with a function, that has the same capabilities with the existing subscriber role within WordPress?
Basically I would like to distinguish between male and female subscribers based on the wordpress role.
A subscriber has only 1 capability namely: read
To create a new (custom)role just add following code-lines in functions.php
.
Please make back-up first and so on….
When added to functions.php
go into the back-end and check if you can add an (new or existing) user to this role.
When all is working you can delete the code because the roles are now added to the database and there is no need to keep them.
/**
* Create new custom role(s)
*
* Subscriber capability set: read
*
* Source {@link https://wordpress.stackexchange.com/q/306353/15605}
* @see {@link https://codex.wordpress.org/add_role}
* @see {@link https://codex.wordpress.org/Roles_and_Capabilities}
*
* @version WordPress 4.9.6
*
*/
// Adjust to your own preferences.
// Subscr_F and M are visible in you back-end, but you can adjust all.
add_role( 'subscr_female', __( 'Subscr_F' ), array( 'read' => true ) );
add_role( 'subscr_male', __( 'Subscr_M' ), array( 'read' => true ) );
I hope this is what you where looking for.