Created
January 19, 2021 10:48
-
-
Save gundamew/6ea6ad1f0d71ab2e89e9bb616c6db70d to your computer and use it in GitHub Desktop.
Create a custom role based on an existing role in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! wp_roles()->is_role( 'my_customer' ) ) { | |
add_role( | |
'my_customer', | |
__( 'My customer' ), | |
array_merge( | |
wp_roles()->get_role( 'customer' )->capabilities, | |
array( 'read_shop_order', 'read_private_shop_orders' ) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment