Support » Plugin: User Registration - Custom Registration Form, Login Form And User Profile For WordPress » How to change the endpoint of an additional tab in the menu?

  • Resolved haste18

    (@haste18)


    Hi,

    First of all, awesome plugin! πŸ™‚

    I’m trying to add an extra tab into the menu by following this manual: https://docs.wpeverest.com/user-registration/docs/how-to-add-additional-tabs-in-my-account/

    It’s working, but I can’t seem to change the endpoint from ‘new-item’ to anything else to get it to work properly. Once I change it to another name to something else the function user_registration_new_item_endpoint_content() is not showing the content, but just hard linking to a new page.

    This is my code. I would like to change ‘new-item’ to ‘bookings’ so the URL is shown as /booking instead of /new-item.

    And it should show the content fetched from page with ID 785.

    add_filter( 'user_registration_account_menu_items', 'ur_custom_menu_items', 10, 1 );
    function ur_custom_menu_items( $items ) {
        $items['new-item'] = __( 'Bookings', 'user-registration' );
        return $items;
    }
    
    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 );
    }
    
    function user_registration_new_item_endpoint_content() {
    	$my_id = 785;
    	$post_id_785 = get_post($my_id);
    	$content = $post_id_785->post_content;
    	$content = apply_filters('the_content', $content);
    	$content = str_replace(']]>', ']]>', $content);
    	echo $content;
    }
    add_action( 'user_registration_account_new-item_endpoint', 'user_registration_new_item_endpoint_content' );

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter haste18

    (@haste18)

    I managed to get it working. Only had to change the last line of this code:

    function user_registration_new_item_endpoint_content() {
    	$my_id = 785;
    	$post_id_785 = get_post($my_id);
    	$content = $post_id_785->post_content;
    	$content = apply_filters('the_content', $content);
    	$content = str_replace(']]>', ']]>', $content);
    	echo $content;
    }
    add_action( 'user_registration_account_new-item_endpoint', 'user_registration_new_item_endpoint_content' );

    to

    function user_registration_new_item_endpoint_content() {
    	$my_id = 785;
    	$post_id_785 = get_post($my_id);
    	$content = $post_id_785->post_content;
    	$content = apply_filters('the_content', $content);
    	$content = str_replace(']]>', ']]>', $content);
    	echo $content;
    }
    add_action( 'user_registration_account_bookings_endpoint', 'user_registration_new_item_endpoint_content' );
    • This reply was modified 1 year, 11 months ago by haste18.
Viewing 1 replies (of 1 total)
  • The topic ‘How to change the endpoint of an additional tab in the menu?’ is closed to new replies.