Support » Plugins and Hacks » Achievements for WordPress » Redirect non logged in users

Redirect non logged in users

  • 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!


Viewing 1 replies (of 1 total)
  • Plugin Author Paul Gibbs


    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Redirect non logged in users’ is closed to new replies.
Skip to toolbar