• Resolved coxinha

    (@coxinha)


    Hi guys,

    I’ve still got following problem:

    I’d like to extend the account page with a custom tab. So I put this code in my functions.php (it’s 1:1 from UM page https://docs.ultimatemember.com/article/65-extend-ultimate-member-account-page-with-custom-tabs-content):

    /* add new tab called "mytab" */
    
    add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 );
    function my_custom_tab_in_um( $tabs ) {
    	$tabs[800]['mytab']['icon'] = 'um-faicon-pencil';
    	$tabs[800]['mytab']['title'] = 'My Custom Tab';
    	$tabs[800]['mytab']['custom'] = true;
    	return $tabs;
    }
    	
    /* make our new tab hookable */
    
    add_action('um_account_tab__mytab', 'um_account_tab__mytab');
    function um_account_tab__mytab( $info ) {
    	global $ultimatemember;
    	extract( $info );
    
    	$output = $ultimatemember->account->get_tab_output('mytab');
    	if ( $output ) { echo $output; }
    }
    
    /* Finally we add some content in the tab */
    
    add_filter('um_account_content_hook_mytab', 'um_account_content_hook_mytab');
    function um_account_content_hook_mytab( $output ){
    	ob_start();
    	?>
    		
    	<div class="um-field">
    		
    		<!-- Here goes your custom content -->
    		
    	</div>		
    		
    	<?php
    		
    	$output .= ob_get_contents();
    	ob_end_clean();
    	return $output;
    }

    Funny fact: In the content there appears a button with the name of the tab which I can’t edit or remove.

    So please tell me how to remove it because it’s senseless to have a button there I can’t edit.

    Thanks a lot in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter coxinha

    (@coxinha)

    Hi again,

    I think I’ve found the reason after a close look in class-account.php:

    /**
    * UM hook
    *
    * @type action
    * @title um_after_account_{$tab_id}
    * @description Make some action after show account tab
    * @input_vars
    * [{"var":"$args","type":"array","desc":"Account Page Arguments"}]
    * @change_log
    * ["Since: 2.0"]
    * @usage add_action( 'um_after_account_{$tab_id}', 'function_name', 10, 1 );
    * @example
    * <?php
    * add_action( 'um_after_account_{$tab_id}', 'my_after_account_tab', 10, 1 );
    * function my_after_account_tab( $args ) {
    *     // your code here
    * }
    * ?>
    */
    do_action( "um_after_account_{$tab_id}", $args );
    
    if ( ! isset( $tab_data['show_button'] ) || false !== $tab_data['show_button'] ) { ?>
    
    <div class="um-col-alt um-col-alt-b">
    <div class="um-left">
    <input type="submit" name="um_account_submit" id="um_account_submit"  class="um-button" value="<?php echo ! empty( $tab_data['submit_title'] ) ? $tab_data['submit_title'] : $tab_data['title']; ?>" />
    </div>
    
    <?php
    /**
    * UM hook
    *
    * @type action
    * @title um_after_account_{$tab_id}_button
    * @description Make some action after show account tab button
    * @change_log
    * ["Since: 2.0"]
    * @usage add_action( 'um_after_account_{$tab_id}_button', 'function_name', 10 );
    * @example
    * <?php
    * add_action( 'um_after_account_{$tab_id}_button', 'my_after_account_tab_button', 10 );
    * function my_after_account_tab_button() {
    *     // your code here
    * }
    * ?>
    */
    do_action( "um_after_account_{$tab_id}_button" ); ?>
    
    <div class="um-clear"></div>
    </div>
    

    As supposed there has been a change since UM 2.0 and that’s why this button appears. So the code above has to be modified because it’s not complete.

    I’m not good in php – is there anyone who can help me here please?

    • This reply was modified 6 years, 6 months ago by coxinha.
    Mike

    (@bigmikey00)

    not sure how this wasnt answered, you are looking at this the wrong way.
    To change the button text is actually simple. Just add the code below to the
    function my_custom_tab_in_um section at the bottom

    $tabs[800]['mytab']['submit_title'] = "test";

    Hope this helps i spent hours myself figuring that out. OBvisouly change test to whatever you want to call it.

    • This reply was modified 6 years, 6 months ago by Mike.
    Thread Starter coxinha

    (@coxinha)

    Hi bigmikey00,

    thanks a lot for your reply and charing your hard work. ??

    Actually I’d like to remove the buttons from “mytab”. Do you have any idea how to do this??

    I am trying to use the Custom Tab snippet to add a tab that links to a new page. Any ideas on how I can adjust this snippet to achieve that.

    In essence, I need to know how I can call a “Help” webpage (https://www&#8230;.) as the link for the new button.

    Hi,

    Add the following line to the function for the custom tab.

    $tabs[800]['mytab']['show_button'] = false;

    For ex,

    add_filter('um_account_page_default_tabs_hook', 'my_custom_tab_in_um', 100 );
    function my_custom_tab_in_um( $tabs ) {
    	$tabs[800]['mytab']['icon'] = 'um-faicon-pie-chart';
    	$tabs[800]['mytab']['title'] = 'Result';
    	$tabs[800]['mytab']['custom'] = true;
    	$tabs[800]['mytab']['show_button'] = false;

    Thanks nilsfolke.

    That successfully removed the button. How can I modify the code to link to a new page as opposed to launching a tab section?

    Thread Starter coxinha

    (@coxinha)

    Thanks a lot nilsfolke – that works like a charm!! ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Problems with extending account page with custom tab’ is closed to new replies.