Skip to:
Content
Pages
Categories
Search
Top
Bottom

Login Redirect to "My Groups" page

Viewing 6 replies - 1 through 6 (of 6 total)
  • @shughey

    Participant

    I am searching for the same, just a redirect after logging in to the groups page, nothing else.

    Thanks

    @shanebp

    Moderator

    >I’ve seen the way you can direct a user to their profile

    Use the same approach and replace the profile url with the groups url.

    bp_core_redirect( get_option('home') . '/groups/' );

    @shughey

    Participant

    shanebp,

    I appreciate your suggestion but I’ve no idea where to begin with this. Am I supposed to add the code to bp-core, or where?

    @shanebp

    Moderator

    If your groups are at url/groups/
    then try pasting the code below into your theme / functions.php

    It should redirect non-admins to the groups page.

    based on https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect

    function shug_login_redirect( $redirect_to, $request, $user ) {
    	//is there a user to check?
    	global $user;
    	if ( isset( $user->roles ) && is_array( $user->roles ) ) {
    		//check for admins
    		if ( in_array( 'administrator', $user->roles ) ) {
    			// redirect them to the default place
    			return $redirect_to;
    		} else {
    			return home_url('/groups/');
    		}
    	} else {
    		return $redirect_to;
    	}
    }
    add_filter( 'login_redirect', 'shug_login_redirect', 10, 3 );

    @shughey

    Participant

    Thanks, I’ll work on it.

    @shughey

    Participant

    Worked!!! Thanks!!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Login Redirect to "My Groups" page’ is closed to new replies.
Skip to toolbar