fbpx

How can we help?

How to add my registrations on my account page

The My Registration page allows your registered users to view all the events they have registered for in a centralized location. The page can be created with the shortcode [my_registrations].

You can also create the My Registration page in the My Account section of the website. In this guide, we will tell you the steps using which you can perform the task.

By adding the following snippet to the functions.php file of a child theme, you can easily build the My Registration page in the My Account Section.

Note: Please ensure that the Sell ticket, Registration addons are active on the website. This is essential to work with the below mentioned shortcodes.


// ------------------
// 1. Register new endpoint to use for My Account page
// Note: Resave Permalinks or it will give 404 error
function wpem_add_my_registrations_endpoint() {
add_rewrite_endpoint( 'my-registrations', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'wpem_add_my_registrations_endpoint' );
// ------------------

// 2. Add new query var
function wpem_my_registrations_query_vars( $vars ) {
$vars[] = 'my-registrations';
return $vars;
}
add_filter( 'query_vars', 'wpem_my_registrations_query_vars', 0 );
// ------------------

// 3. Insert the new endpoint into the My Account menu
function wpem_add_my_registrations_link_my_account( $items ) {
$items['my-registrations'] = 'My Registrations';
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'wpem_add_my_registrations_link_my_account' );
// ------------------

// 4. Add content to the new endpoint
function wpem_my_registrations_content() {
echo '
My Registrations
';
echo do_shortcode( '[my_registrations]' );
}
add_action( 'woocommerce_account_my-registrations_endpoint', 'wpem_my_registrations_content');

Was this article helpful?
How can we improve this article?
How Can We Improve This Article?
Quick Links
Close