• Hi,

    I am following the guide: https://wpusermanager.com/article/234-how-to-add-a-new-tab-to-the-edit-account-page/

    I have managed to add the tab using the code:

    <?php
    
    /**
     * Register a new tab within the account page.
     *
     * @param array $tabs
     *
     * @return array
     */
    function my_wpum_register_new_account_tabs( $tabs ) {
    
    	$tabs['custom-slug'] = [
    		'name'     => esc_html__( 'Custom Title' ),
    		'priority' => 3, // Change this to define the position in the menu
    	];
    
    	return $tabs;
    
    }
    add_filter( 'wpum_get_account_page_tabs', 'my_wpum_register_new_account_tabs' );
    

    However, the second set of code in the article…I do not know where to put it…?

    <?php
    
    function my_wpum_account_tab_content() {
      // render content
    }
    
    add_action( 'wpum_account_page_content_custom-slug', 'my_wpum_account_tab_content' );

    Any help would be greatly appreciated, please.

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Mark Kevin

    (@mkesteban08)

    Hi @wowjamweb ,

    You can proceed in adding the snippet within your child-theme’s function.php file.

    If that does not work for you, please let me know, and I’ll be glad to assist you. Have a great day ahead!

    Thread Starter James Fotheringham

    (@wowjamweb)

    It still isn’t working – this is the code I have got….

    A new php file in mu-plugins

    <?php
    
    /**
     * Register a new tab within the account page.
     *
     * @param array $tabs
     *
     * @return array
     */
    function my_wpum_register_new_account_tabs( $tabs ) {
    
    	$tabs['profile-picture'] = [
    		'name'     => esc_html__( 'Profile Picture' ),
    	];
    	$tabs['marketing-preferences'] = [
    		'name'     => esc_html__( 'Marketing Preferences' ),
    	];
    	$tabs['delete-account'] = [
    		'name'     => esc_html__( 'Delete Account' ),
    	];
    	return $tabs;
    
    }
    add_filter( 'wpum_get_account_page_tabs', 'my_wpum_register_new_account_tabs' );
    

    and within functions.php

    function my_wpum_account_tab_content() {
      // render content
    }
    
    add_action( 'wpum_account_page_content_profile-picture', 'my_wpum_account_tab_content' );
    

    Any help would be greatly appreciated.

    Thanks.

    Thread Starter James Fotheringham

    (@wowjamweb)

    @mkesteban08 ,

    Just wondered if you could take a look at the code I’ve posted to see if anything springs to mind please, about why it wouldn’t be working?

    Thanks in advance!

    Plugin Author WP User Manager

    (@wpusermanager)

    Hey @wowjamweb what doesn’t seem to be working?

    I’ve tested your code and the tabs get added. If you echo something in the my_wpum_account_tab_content function it will display when you visit the ‘Profile Picture’ tab

    Thread Starter James Fotheringham

    (@wowjamweb)

    @wpusermanager That works for 1 additional tab. When I add more code for additional tabs like…

     
    /* ADDITIONAL TABS ON EDIT ACCOUNT */
    function my_wpum_account_tab_content() {
      // render content
        echo "test";
    }
    
    add_action( 'wpum_account_page_content_marketing-preferences', 'my_wpum_account_tab_content' );
    

    It breaks the site and displays an error saying a critical error has occurred. Any ideas, please?

    Thanks, in advance.

    Plugin Author WP User Manager

    (@wpusermanager)

    The function my_wpum_account_tab_content needs to be unique for every tab

    Thread Starter James Fotheringham

    (@wowjamweb)

    Thank you so much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘New Tab in the Edit Account page’ is closed to new replies.