WordPress Development Asked by Nayan Chowdhury on March 9, 2021
I have written the below script to restrict users to access bbpress forums or topics. Here are the conditions:
The problem here is for topics in forum it is working except the latest created topic. And it is taking user to “Join” page even if the user is logged in and have the “pmpro_role_1”. What is happening here?
Please help.
add_action ('template_redirect', 'forum_security');
function forum_security(){
$roles = wp_get_current_user()-> roles;
if(is_singular( array( 'forum', 'topic' ) )){
if(!is_user_logged_in()){
wp_redirect('/join');
exit;
}else{
if(current_user_can('administrator')){
return;
}elseif(!in_array('pmpro_role_1', $roles)){
wp_redirect('/product/channel-mcgilchrist');
exit;
}
}
}
}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP