Last active
September 22, 2017 21:38
-
-
Save m-e-h/10516a6409e45e937bb78d290e242622 to your computer and use it in GitHub Desktop.
Map taxonomy terms to Members roles
This file contains hidden or 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 | |
add_filter( 'members_can_user_view_post', 'smcs_tax_content_permissions' ); | |
function smcs_tax_content_permissions( $can_view, $user_id, $post_id ) { | |
$terms = get_terms( array( | |
'taxonomy' => 'smcs_access', | |
) ); | |
if ( ! empty( $terms ) ) { | |
$can_view = false; | |
if ( rcp_is_restricted_content( $post_id ) && rcp_user_can_access( $user_id, $post_id ) ) { | |
$can_view = true; | |
} | |
if ( has_term( 'admin-athletics', 'smcs_access' ) ) { | |
if ( members_user_has_role( $user_id, 'sm_sports_admin' ) ) { | |
$can_view = true; | |
} | |
} | |
if ( has_term( 'admin-pto', 'smcs_access' ) ) { | |
if ( members_user_has_role( $user_id, 'sm_pto_admin' ) ) { | |
$can_view = true; | |
} | |
} | |
} | |
return $can_view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment