• andersonmichel

    (@andersonmichel)


    I didnt find setting options to do what I wrote in the title.

    Actually my Custom Post Type should be in the dashboard menu insted of the Posts link.

    What can I do to fix this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Mushrit Shabnam

    (@611shabnam)

    Hello @andersonmichel,

    This needs customization as by default it will be unavailable to show custom post type post in the account page and to remove the posts tab from the account page.

    In order to remove the posts tab from the account page, please add the following code in your child theme’s functions.php file:

    
    add_filter('wpuf_my_account_tab_links', 'remove_posts_link');
    
    function remove_posts_link($tabs){
    
        if(isset($tabs['posts'])) {
            
            unset($tabs['posts']);
        }
    
        return $tabs;
    }
    
    add_filter('wpuf_account_sections', 'wpuf_get_account_sections_custom' );
    
    function wpuf_get_account_sections_custom($account_sections){
        foreach ($account_sections as $key=>$section) {
            if(isset($section['slug']) && $section['slug'] == 'posts') {
                unset($account_sections[$key]);
            }
        }
        return $account_sections; 
    }
    

    For showing the custom post type post, you need add custom code again. Say you want to show product type post in your account page, so you have to add the following custom code in your child theme’s functions.php file:

    add_filter( 'wpuf_account_sections', 'wpuf_my_page' );
    
    function wpuf_my_page( $sections ) {
    $sections = array_merge( $sections, array( array( 'slug' => 'my-page', 'label' => 'Products' ) ) );
    
    return $sections;
    }
    
    add_action( 'wpuf_account_content_my-page', 'wpuf_my_page_section', 10, 2 );
    
    function wpuf_my_page_section( $sections, $current_section ) {
    
     echo do_shortcode('[wpuf_dashboard post_type="product"]');
    
    }
    

    If you want to show any other custom post type post, just change it in the post_type of the shortcode above.

    Regards,

    @611shabnam Thank you for these snippets
    Altough, isn’t the same as this setting here:
    wp-admin/admin.php?page=wpuf-settings
    My Account -> Post Submission -> Enable if you want to allow users to submit post from the account page.
    ?

    Thanks

    Plugin Support Mushrit Shabnam

    (@611shabnam)

    Hello @anticosti,

    Yes in order to allow submitting custom post type post, you need a little more custom code. This is a very basic way of adding the code. Please add the following code in your child theme’s functions.php file:

    add_filter( 'wpuf_account_sections', 'wpuf_product_page' );
    
    function wpuf_product_page( $sections ) {
    $sections = array_merge( $sections, array( array( 'slug' => 'my-page', 'label' => 'Submit WooCommerce Products form' ) ) );
    
    return $sections;
    }
    
    add_action( 'wpuf_account_content_my-page', 'wpuf_product_page_section', 10, 2 );
    
    function wpuf_product_page_section( $sections, $current_section ) {
    
     echo do_shortcode('[wpuf_form id="9736"]'); /*use your post form's shortcode where you allowed custom post type post*/
    
    }

    Instead of the ID 9736, you have to set your own form ID in the function wpuf_product_page_section() and also change the ‘label’=> ” from the function wpuf_product_page().

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.