By default, the account page of WP User Frontend doesn't show any custom post type posts. The shortcode built page offers to show the default post type post of WordPress. The dashboard page, built with another shortcode [wpuf_dashboard] is the appropriate page to show custom posts because it can accept post type as a parameter.
So how do you show the custom posts on the account page? Simple.
We have to use a bit of custom code block to show a new tab on the account page. Then all we have to do is make the dashboard page action happen in the new tab.
This can help us to show multiple custom post type posts, add more than one "submit post" section or show subscription page directly from account. So let's see how we can do that.
First, we have to insert the code block that we need to add the tab in our WP-content/themes/child-themes/functions.php file:
add_filter( 'wpuf_account_sections', 'wpuf_custom_tab' );
function wpuf_custom_tab( $sections ) {
$sections = array_merge( $sections, array( array( 'slug' => 'my-page', 'label' => 'Custom Posts' ) ) );
return $sections;
}
add_action( 'wpuf_account_content_my-page', 'wpuf_custom_tab_section', 10, 2 );
function wpuf_custom_tab_section( $sections, $current_section ) {
echo do_shortcode('[wpuf_dashboard post_type="custom_post_name"]');
}
So if you are familiar with coding, you can see in the above code we have used a filter and an action hook and have added the callback functions. In the function wpuf_custom_tab_section, we will add the shortcode which will bring the custom post list/subscription list/custom post forms for us.
Now, let's say I want to show the WooCommerce product type post. I will modify the value in the post_type and label is always free to take any label you want.
add_filter( 'wpuf_account_sections', 'wpuf_custom_tab' );
function wpuf_custom_tab( $sections ) {
$sections = array_merge( $sections, array( array( 'slug' => 'my-page', 'label' => 'Submit Product' ) ) );
return $sections;
}
add_action( 'wpuf_account_content_my-page', 'wpuf_custom_tab_section', 10, 2 );
function wpuf_custom_tab_section( $sections, $current_section ) {
echo do_shortcode('[wpuf_dashboard post_type="product"]');
}
In the same way, if you add the subscription page shortcode inside the do_shortcode() function, then you can show all the subscription packs available for the user to choose from.
In a similar process, if you insert a form shortcode inside the do_shortcode() function, that form will be available for the users to submit post from the account page.
That's all folks, hope you found this useful! You can follow me on GitHub and on Twitter.