User Registration

Step by step documentation to set up a user registration form for your website.

How to add additional tabs in my account

To add additional tabs to My Account, you need to add the following code to your theme’s function.php.

Note: These codes will be wiped out after a theme update. So, you need to create a child theme and add the codes there. You can check out this easy Tutorial on Creating a Child Theme.
Also, you can check 'How to add custom code on your site?'. 

So, after creating your Child Theme, you can add these codes in the child theme’s function.php.

We have user_registration_account_menu_items filter hook to add the item to the $items array.

add_filter( 'user_registration_account_menu_items', 'ur_custom_menu_items', 10, 1 );
function ur_custom_menu_items( $items ) {
    $items['new-item'] = __( 'New', 'user-registration' );
    return $items;
}

Adding a new endpoint:

add_action( 'init', 'user_registration_add_new_my_account_endpoint' );
function user_registration_add_new_my_account_endpoint() {
    add_rewrite_endpoint( 'new-item', EP_PAGES );
}

Adding content to a new end point:

function user_registration_new_item_endpoint_content() {
    echo 'Your new content';
}
add_action( 'user_registration_account_new-item_endpoint', 'user_registration_new_item_endpoint_content' );

You can also add the contents from the template file. Create a template in wp-content/themes/your-chosen-theme/user-registration/myaccount/new-item.php and add the content here.
For this your user_registration_new_item_endpoint_content() callback function should point to your template file.

function user_registration_new_item_endpoint_content() {
      ur_get_template( 'myaccount/new-item.php');
}

Also, you can leave the endpoint empty from User Registration->Settings->Geneal to hide the default tabs.

Note: After you have added the above-mentioned codes, go to WordPress Settings>Permalinks and then save the permalink settings. 

Powered by BetterDocs

Scroll to top