• Resolved pandglobal

    (@pandglobal)


    please i want to add more endpoints to the my account page, and i want the endpoint that i will add to have something like a page or text/html area so that i can add my html code there. what i want to see is how to create additional endpoints that i can add html code in it from the admin end.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter pandglobal

    (@pandglobal)

    i want to add more endpoints in my account page, and i want the endpoints to be an html/text file so that i can add html page or content to the endpoints i added from the admin area.
    something like this https://yithemes.com/themes/plugins/yith-woocommerce-customize-myaccount-page/
    so that i can add more endpoint by adding filter in my function.php but will be able to add contents such as shortcodes, html or rich text content in the newly added endpoint from the admin area, something like page editor for each newly added endpoint.

    Hello @pandglobal,

    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');
    }

    Regards,
    WPEverest Support

    Thread Starter pandglobal

    (@pandglobal)

    Thanks very much but how can I make the contents or the new-item template i created to be editable on admin backend so that i can add shortcodes to it, you know i can’t add shortcodes on template files, these means i can use any kind of WordPress shortcodes on my new backend editable template.

    You can add shortcodes to the template files too: Suppose, in your newly created template file new-item.php add:
    <?php echo do_shortcode('[user_registration_form id="4"]'); ?>

    However, you can also create a page. Edit the page from backend and get the content by post id from your newly created new-item.php template file.
    <?php echo apply_filters('the_content', get_post_field('post_content', $post_id)); ?>

    But, the former is recommended way.

    Thread Starter pandglobal

    (@pandglobal)

    thanks i prefer the later than the former, because it will allow me create a full flegded page with contents, images and shortcodes too and then append it in a template.

    Thread Starter pandglobal

    (@pandglobal)

    thanks again

    Hello @pandglobal,

    Glad to know you find out the way, if you have time to spare we will really appreciate a review to the plugin. https://ww.wp.xz.cn/support/plugin/user-registration/reviews/?filter=5

    Thanks,

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘How to add additional endpoints’ is closed to new replies.