-
Author
-
October 1, 2017 at 03:04 #175309ysfcnParticipant
hi, ı want to restrict buddypress access for non-logged user. ı am adding this code to my functions.php file in the child theme but it is not working. what am ı doing wrong ? ı dont know. can you help me please?
COPY CODE/** * Redirect buddypress and bbpress pages to registration page */ function kleo_page_template_redirect() { //if not logged in and on a bp page except registration or activation if( ! is_user_logged_in() && ( ( ! bp_is_blog_page() && ! bp_is_activation_page() && ! bp_is_register_page() ) || is_bbpress() ) ) { wp_redirect( home_url( '/register/' ) ); exit(); } } add_action( 'template_redirect', 'kleo_page_template_redirect' );
October 1, 2017 at 17:41 #175343Kieran_SQModeratorHi,
Thanks for reaching out about redirecting logged out users to the register page, I think the issue may be coming from not having bbPress installed, if that is the case changing the code to remove the bbPress element should work. Please add the below to the end of your KLEO Child theme’s functions.php file by going to Appearance > Editor > KLEO Child > functions.php
COPY CODE// Redirect logged out to register page if pages are BuddyPress function kleo_page_template_redirect() { // if not logged in and on a bp page except registration or activation if( ! is_user_logged_in() && ( ( ! bp_is_blog_page() && ! bp_is_activation_page() && ! bp_is_register_page() ) ) ) { wp_redirect( home_url( '/register/' ) ); exit(); } } add_action( 'template_redirect', 'kleo_page_template_redirect' );
Thanks,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
October 3, 2017 at 18:54 #175571ysfcnParticipantunfortunately this code did not work by the way bbPress installed.
// Redirect logged out to register page if pages are BuddyPress
function kleo_page_template_redirect()
{
// if not logged in and on a bp page except registration or activation
if( ! is_user_logged_in() &&
( ( ! bp_is_blog_page() && ! bp_is_activation_page() && ! bp_is_register_page() ) )
)
{
wp_redirect( home_url( ‘/register/’ ) );
exit();
}
}
add_action( ‘template_redirect’, ‘kleo_page_template_redirect’ );October 3, 2017 at 19:33 #175576ysfcnParticipantı think my KLEO Child theme’s functions.php is not working. because ı paste this code and try it bot not working. 🙂
add_action( ‘wp_footer’, ‘message_when_logged_in’ );
function message_when_logged_in() {
if ( is_user_logged_in() ) {
echo ‘logged in’;
} else {
echo ‘not logged in’;
}
}October 3, 2017 at 20:50 #175578ysfcnParticipantı paste this code kleo/function.php and its work succesfully. why kleo chilt function.php doesnt work?
// Redirect logged out to register page if pages are BuddyPress
function kleo_page_template_redirect()
{
// if not logged in and on a bp page except registration or activation
if( ! is_user_logged_in() &&
( ( ! bp_is_blog_page() && ! bp_is_activation_page() && ! bp_is_register_page() ) )
)
{
wp_redirect( home_url( ‘/register/’ ) );
exit();
}
}
add_action( ‘template_redirect’, ‘kleo_page_template_redirect’ );October 5, 2017 at 22:32 #175777Kieran_SQModeratorHi,
Please can you update this ticket with admin credentials in a private reply so I can take a look at your child theme.
Thanks,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.