Custom Endpoint Created, but I need to target a dynamic page that doesn't exist - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, October 7, 2022

Custom Endpoint Created, but I need to target a dynamic page that doesn't exist

I currently have a Code Snippet that's creating a custom tab through the WooCommerce Menu called 'Device Profile':

function AddCustomTabEndpoint() {
  add_rewrite_endpoint('Device-Profile', EP_ROOT | EP_PAGES );
}
add_action('init','AddCustomTabEndpoint' );

function CustomTabQueryVars( $vars ) {
  $vars[] = 'Device-Profile';
  return $vars;
}
add_filter('query_vars','CustomTabQueryVars', 0 );

function AddCustomTabMyAccount( $items ) {
  $items['Device-Profile'] = 'My Custom Tab';
  return $items;
}
add_filter('woocommerce_account_menu_items','AddCustomTabMyAccount');

function MyCustomTabContent() {
  echo "<h3>Device-Profile</h3><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>";
}
add_action('woocommerce_account_Device-Profile_endpoint','MyCustomTabContent');

..but now there is a brick wall. I can't point the menu link to a specific page because it doesn't exist. The page is created after a user submits a form which would look something like https://www.123.com/page_is_built/12345.

This URL doesn't lead anywhere, but as a reference, "page_is_built" would define the subdirectory and "12345" would be the endpoint that needs to be targeted. Again, this doesn't exist until the user submits a form on the website. I also can't predict what the endpoint URL will be... So how would I target the endpoint?



source https://stackoverflow.com/questions/73978317/custom-endpoint-created-but-i-need-to-target-a-dynamic-page-that-doesnt-exist

No comments:

Post a Comment