Adding Additional Tab to Default User Profile Theme - ProfilePress

Adding Additional Tab to Default User Profile Theme

If you are using the Default user profile theme from ProfilePress to power the display of every user profile on your site, this tutorial is for you.

By default, the theme comes with only three tabs – About, Posts and Comments.

Use the code below to add a tab menu that links to a specific URL.

add_filter('ppress_dpf_saved_tabs', function ($tabs) {
    $tabs[] = 'custom_link_id_here';
    return $tabs;
});

add_filter('ppress_profile_tabs', function ($tabs) {
    $tabs['custom_link_id_here'] = [
        'icon'  => 'url',
        'title' => esc_html__('Custom Link Label', 'wp-user-avatar'),
        'url' => 'https://link-to-url-here.com'
    ];

    return $tabs;
});

If you want to add a tab to display custom content, see the code snippet below which will display the user’s display name when the custom tab menu is clicked.

add_filter('ppress_dpf_saved_tabs', function ($tabs) {
    $tabs[] = 'custom_link_id_here';
    return $tabs;
});

add_filter('ppress_profile_tabs', function ($tabs) {
    $tabs['custom_link_id_here'] = [
        'icon'  => 'url',
        'title' => esc_html__('Custom Link Label', 'wp-user-avatar')
    ];

    return $tabs;
});


add_action('ppress_profile_tab_content_custom_link_id_here', function () {

    /** @var \WP_User */
    global $ppress_frontend_profile_user_obj;

    echo $ppress_frontend_profile_user_obj->display_name;
});