WordPress.org

Forums

Achievements for WordPress
Redirect non logged in users (2 posts)

  1. Mike L
    Member
    Posted 2 years ago #

    I'm using Achievements on a private website that requires member login to view BuddyPress components. I can get everything to redirect to the login page except the Achievements slug.

    This part doesn't seem to work: $bp->current_component == $bp->achievements->slug

    function bp_restrict_access() {
    
    	global $bp, $bp_unfiltered_uri;
    	$redirect_after_login = 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    	$login_url = wp_login_url( $redirect_after_login );
    
    	if (!is_user_logged_in() && (BP_MEMBERS_SLUG == $bp_unfiltered_uri[0] || BP_GROUPS_SLUG == $bp->current_component || BP_BLOGS_SLUG == $bp->current_component || BP_FORUMS_SLUG == $bp->current_component || BP_ACTIVITY_SLUG == $bp->current_component || $bp->current_component == $bp->achievements->slug ) ) {
    		bp_core_redirect( $login_url . '?login=false' );
    	}
    }
    add_action( 'wp', 'bp_restrict_access', 3 );

    Help would be appreciated, thanks!

    http://wordpress.org/extend/plugins/achievements/

  2. Paul Gibbs
    BuddyPress Lead Developer
    Plugin Author

    Posted 2 years ago #

    What doesn't work?

    You'll need to debug this, and find out what the value of $bp->current_component and $bp->achievements->slug is when you go onto the page where you want the redirect to happen from.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Achievements for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic