Use user_can function

Use user can rather than roles directly.

If the user can edit posts, assume they are allowed an archive.

Fixes #15508
This commit is contained in:
Mike Jolley 2017-06-09 15:18:35 +01:00
parent 5fe26e689c
commit 4367c9f6d4
1 changed files with 1 additions and 1 deletions

View File

@ -507,7 +507,7 @@ function wc_disable_author_archives_for_customers() {
if ( is_author() ) {
$user = get_user_by( 'id', $author );
if ( isset( $user->roles[0] ) && 'customer' === $user->roles[0] ) {
if ( user_can( $user, 'customer' ) && ! user_can( $user, 'edit_posts' ) ) {
wp_redirect( wc_get_page_permalink( 'shop' ) );
}
}