Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Different BP profile landing page for different user role

  • @had_hc

    Participant

    Hi all, i’m trying to set different BP profile landing page for different user roles.

    Here’s what i’ve tried;

    function bp_default_tab (){
    	global $bp;
            if ( bp_is_user() ) {
    	$wcv_profile_info = get_userdata( bp_displayed_user_id() );
    	if ( $wcv_profile_info->roles[0] == "vendor" ){
    				 define('BP_DEFAULT_COMPONENT', 'my-store' );
    			} else {
    				define('BP_DEFAULT_COMPONENT', 'following' );
    			}
            }
    }
    add_action( 'bp_loaded', 'bp_default_tab' );
    

    With this code, landing profile change only set to the ‘else’ (following in regards to code above). Couldn’t manage to change for the ‘vendor’ user role. Anybody have any idea how?
    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • @modemlooper

    Moderator

    Try bp_init instead of loaded, but define’s usually need to be added before bp is loaded and then bp_displayed_user_id isn’t ready.

    If you can’t get it to work then you might try a redirect http://hookr.io/functions/bp_core_redirect/

    @had_hc

    Participant

    After some googling, I found the answer from here! The action ‘bp_core_setup_globals’ is the answer and it works well!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Different BP profile landing page for different user role’ is closed to new replies.
Skip to toolbar