Skip to content

Instantly share code, notes, and snippets.

@gundamew
Created January 19, 2021 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gundamew/6ea6ad1f0d71ab2e89e9bb616c6db70d to your computer and use it in GitHub Desktop.
Save gundamew/6ea6ad1f0d71ab2e89e9bb616c6db70d to your computer and use it in GitHub Desktop.
Create a custom role based on an existing role in WordPress.
<?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