• Resolved eliac7

    (@eliac7)


    function custom_tab_3( $tabs ) {
    
         $hide_from_roles_3otab = array('um_custom_role_2','um_custom_role_3', 'administrator');
        if (is_user_logged_in() && !in_array(um_user('role'), $hide_from_roles_3otab)) {
    
    	$tabs[ 'aggelies' ] = array(
    		'name'   => 'Οι αγγελ?ε? μου',
    		'custom' => true
        );
    }
    
    	UM()->options()->options[ 'profile_tab_' . 'aggelies' ] = true;
    
    	return $tabs;
    }
    add_filter( 'um_profile_tabs', 'custom_tab_3', 2 );
    

    I have the above code, and I am trying to make this tab the “active” tab of the profile. By active, I mean when the user visits their profile, to be this as the first one that is already “clicked”. Any ideas?

    Best Regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Towhid

    (@cryptex_vinci)

    Hi @eliac7

    Follow these steps:

    1. Go to Ultimate Member > Settings
    2. Then Navigate to Appearance > Profile Menu
    3. Select your custom tab (Οι αγγελ?ε? μου) from “Profile menu default tab” dropdown.
    4. Click on “Save Changes”

    Thanks

    Thread Starter eliac7

    (@eliac7)

    Dear Asif,
    Thanks for the reply.

    Well, I knew that option but due to using the if (is_user_logged_in() && !in_array(um_user('role'), $hide_from_roles_3otab)), it just disappears that option.

    View post on imgur.com

    I am using that “if” because I want a specific role owns that tab and not every role on my site. So, I think there should be a snippet or a line of code available that I could add to my function to make it primary.

    Thanks for your time!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @eliac7

    Try adding the !is_admin() to the condition.

    if (is_user_logged_in() && !in_array(um_user('role'), $hide_from_roles_3otab) && !is_admin() ){
       
    }

    Regards,

    Thread Starter eliac7

    (@eliac7)

    Thanks for the reply, but I don’t know what your answer truly answers. My issue is that my custom profile tab is not the active one when I visit the profile. If I remove the above “if”, it displays me the option from the appearance menu but if I add that if(which I need it), then it just “hides” me the option to choose which tab I want to be primary. I tried the && !is_admin() but nothing changed :/ (and no option shows up on appearance menu).

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @eliac7

    Please try this code snippet:

    function custom_tab_3( $tabs ) {
    
         $hide_from_roles_3otab = array('um_custom_role_2','um_custom_role_3', 'administrator');
    
         $tabs[ 'aggelies' ] = array(
    		'name'   => 'Οι αγγελ?ε? μου',
    		'custom' => true
        );
    
        if (is_user_logged_in() && in_array(um_user('role'), $hide_from_roles_3otab) && !is_admin() ) {
             unset( $tabs[ 'aggelies' ] );
    	
    }
    
    	UM()->options()->options[ 'profile_tab_' . 'aggelies' ] = true;
    
    	return $tabs;
    }
    add_filter( 'um_profile_tabs', 'custom_tab_3', 2 );
    

    Regards,

    Thread Starter eliac7

    (@eliac7)

    Dear Champ,
    Thanks for the snippet. Seems not working, but it’s okay! I would like to ask one more thing. I want to make the above tab available only to the current user who has that role. I mean, to be restricted only to the current user and no one with the same role can see that. Any ideas on how this can be done?

    • This reply was modified 4 years ago by eliac7.
    • This reply was modified 4 years ago by eliac7. Reason: typo
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @eliac7

    You can use this condition to check if the current viewing profile is the logged-in user’s profile:

    if (um_is_myprofile()) {
    
    }

    Regards,

    Thread Starter eliac7

    (@eliac7)

    Dear Champ,
    Thanks a lot! You are a lifesaver. Nonetheless, still, the code about the default tab doesn’t work. Let me explain better. I have two roles. Each role has a different tab. So, let’s say the “Business” role has the A tab and the “Consumer” role has the B tab. I want the “Business” role to have as primary his tab “A” and the “Consumer” role has as the primary the B role. If I delete the “if” on the above code, it appears on the Appearance Menu the option to choose the tab I want as default, but if I check the “A” tab to be as primary, the “B” tab is not checked as primary (it seems logic), so this is what I am trying to do. I have successfully selected the A tab as primary for the “Business” role but for the role with the other tab (Consumer with B tab) is not selected as primary.

    Hopefully, I made my self more clear.

    Best Regards,
    Elias

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom Tab – make it as primary tab’ is closed to new replies.