1. Home
  2. WP User Frontend Pro
  3. Developer Docs
  4. 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 4th line like this

$sections = array_merge( $sections, array( array( 'slug' => '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 )
    );
}

On line number 7 the digits represent the order and priority respectively. So depending on the number, the tab orders can be changed.

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? Yes No 1

How can we help?