How to add a custom section-menu on WPUF Account page

This short article will show how to add a custom post type menu over the WPUF My Account Page.

If you are using WP User Frontend Plugin, then you will notice that by default, WPUF will only let you allow to show the default WordPress posts over the My Account page.

However, if you want to show the custom post types like Product and Events over the My Account page, how to do that?

To do that, you can inject this snippet on your theme/child theme’s functions.php file to show the associated custom post types Menu/Tab over the My Account Page.

/* Add a new post type (Event) on the WPUF Account page start */

add_filter( 'wpuf_account_sections', 'wpuf_my_event_page' );

function wpuf_my_event_page( $sections ) {
$sections = array_merge( $sections, array( array( 'slug' => 'event', 'label' => 'Events' ) ) );

return $sections;
}

add_action( 'wpuf_account_content_event', 'wpuf_my_event_page_section', 10, 2 );

function wpuf_my_event_page_section( $sections, $current_section ) {

 echo do_shortcode('[wpuf_dashboard post_type="tribe_events"]'); //your post type (Tribe Events)

}
/* Add a new post type (Event) on the WPUF Account page End */

/* Add a new post type (Product) on the WPUF Account page start */

add_filter( 'wpuf_account_sections', 'wpuf_my_product_page' );

function wpuf_my_product_page( $sections ) {
$sections = array_merge( $sections, array( array( 'slug' => 'product', 'label' => 'Products' ) ) );

return $sections;
}

add_action( 'wpuf_account_content_product', 'wpuf_my_product_section', 10, 3 );

function wpuf_my_product_section( $sections, $current_section ) {

 echo do_shortcode('[wpuf_dashboard post_type="product"]'); //your post type (product)

}
/* Add a new post type (Product) on the WPUF Account page End */

Yoo! If everything is okay, you will notice the above-created post types Menu over the My Account page.

Custom Post Types Menu on the My Account Page

This is all for now. See you in the next post 🙂

MM Aurangajeb
MM Aurangajeb

Spreading Happiness. Support Engineer, WordPress Enthusiast, Blogger.

Articles: 18

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.