Skip to:

redirecting album page when not logged in

  • dangwhatno


    I’ve set up my buddypress installation to redirect to the home page if a user is not logged in, using this code in functions.php:

    `function bp_guest_redirect() {
    global $bp;
    if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_forums_component() || bp_is_members_component() || bp_is_page( BP_ALBUM_SLUG ) || bp_is_profile_component() || bp_is_messages_component() || bp_is_settings_component() ) {
    // enter the slug or component conditional here
    if(!is_user_logged_in()) { // not logged in user
    wp_redirect( get_option(‘siteurl’) . ” );
    } // user will be redirect to any link to want

    However, when I added the BP Album+ stable release plugin, the album page doesn’t redirect along with the rest of the site. I assume I need to add another declaration for the album page (tried `bp_is_album_component()` and `bp_is_page( BP_ALBUM_SLUG )`, both didn’t work. what am i doing wrong?

Viewing 1 replies (of 1 total)

  • foxly



    The bp_is_album_component() and bp_is_page( BP_ALBUM_SLUG ) tests won’t work because those functions don’t exist in BP-Album …they’re “BuddyPress Only” concepts.

    Try adding your test/redirect code to the top of each of BP-Album’s template files. If it still doesn’t work (due to BuddyPress trying to wrap them with HTML output), then you’ll have to hook on the “bp_album_load_template_filter” filter and run your test/redirect code in there.


Viewing 1 replies (of 1 total)
  • The topic ‘redirecting album page when not logged in’ is closed to new replies.
Skip to toolbar