On the site, users fill in a form that creates their page on the website to display information. Within the My Account page, I’ve created a link that takes the logged-in user to the WordPress dashboard where they can edit this page.
// Add Store link WooCommerce Navigation
add_filter ( 'woocommerce_account_menu_items', 'one_more_link' );
function one_more_link( $menu_links ){
$new = array( 'stall-page' => 'Edit Stall Information' );
$menu_links = array_slice( $menu_links, 0, 1, true )
+ $new
+ array_slice( $menu_links, 1, NULL, true );
return $menu_links;
}
// hook the URL
add_filter( 'woocommerce_get_endpoint_url', 'hook_endpoint', 10, 4 );
function hook_endpoint( $url, $endpoint, $value, $permalink ){
if( 'stall-page' === $endpoint ) {
$url = 'https://websitename.com/wp-admin/edit.php?post_type=stallholders';
}
return $url;
}
I want to take it one step further and link directly to the page they need to edit.
I’ve been experimenting and gotten as far as this:
// hook the URL
add_filter( 'woocommerce_get_endpoint_url', 'hook_endpoint', 10, 4 );
function hook_endpoint( $url, $endpoint, $value, $permalink ){
$current_user = wp_get_current_user();
$post_id = $current_user->post_ID;
if( 'stall-page' === $endpoint ) {
$url = 'https://websitename.com/wp-admin/post.php?post=' . $post_id . '&action=edit';
}
return $url;
}
But this is linking to the users ID and not their custom post type page?