I have been trying but I do not achieve results. I wish that only the author of the post and the users with the shop_manager role can see it, if not redirect the page. If they are authors but they didnt write the post, they wont be able to access it.
the code works for everything except shop_manager users can see it.
function wpso_author_redirection() {
if ( is_single() ) {
$current_post_details = get_post( get_the_ID(), ARRAY_A );
$user_id = get_current_user_id();
if ($user_id != absint( $current_post_details['post_author']) ||$user
['roles']!= 'shop_manager' ) {
wp_redirect( 'https://aa.com/contenido-bloqueado');
}
}
}
Aucun commentaire:
Enregistrer un commentaire