1. Home
  2. Docs
  3. WP User Frontend Documentation
  4. Developer Docs
  5. Add A New Tab On My Account Page

Add A New Tab On My Account Page

We have added a new shortcode to show all the user data on one page. The short code [[wpuf_account]] adds helpful information on the same page and organizes them in tabs.

If you want to add your own page on the tab, you can use the filter wpuf_account_sections. It works based on page slugs.

Adding your own page

If you want to add a page that has the slug `your-score`, then you have to replace the following line of code accordingly.

$sections = array_merge( $sections, array( array( 'slug' =>;gt; 'your-score', 'label' => 'Scoreboard' ) ) );

Now you have to change the action and function accordingly. So the action would look like this:

add_action( 'wpuf_account_content_your-score', 'wpuf_your_score_section', 10, 2 );

function wpuf_your_score_section( $sections, $current_section ) {
    wpuf_load_template(
        "my-page.php",
        array( 'sections' => $sections, 'current_section' => $current_section )
    );
}

The digits in the following code:

 add_action ( 'wpuf_account_content_my-page', 'wpuf_my_page_section', 10, 2 ); 

represent the order and priority respectively. So depending on the number, the tab orders can be changed. It is to be noted that you can override default templates or load any custom template. To override a built-in template follow the instructions in How To Override Templates. In order to create a custom template, follow the same instructions as overriding templates and add the template filename to following line of code. For example if we add a custom template as “my-page.php” then our code will look like following

wpuf_load_template(
"my-page.php",
array( 'sections' => $sections, 'current_section' => $current_section )
);

Example

add_filter( 'wpuf_account_sections', 'wpuf_my_page' );

function wpuf_my_page( $sections ) {
$sections = array_merge( $sections, array( array( 'slug' => 'my-page', 'label' => 'My Page' ) ) );

return $sections;
}

add_action( 'wpuf_account_content_my-page', 'wpuf_my_page_section', 10, 2 );

function wpuf_my_page_section( $sections, $current_section ) {
wpuf_load_template(
"my-page.php",
array( 'sections' => $sections, 'current_section' => $current_section )
);
}

Was this article helpful to you?

How can we help?