hybrid
hybrid copied to clipboard
possible to open custom url in menu
Hi shprink,
I have custom endpoint via rest api, which show profile page of user / sitemap of site etc and it is generated via PHP, so its not created via standard "Pages". It is possible to route this fake page in menu.json? I have idea, how can hack
in menu.json "public.pages.id({ id: MYFAKEID, for example 999999999 })" via filter rest api, if is id == 99999999, than generate profile page
add_filter('rest_prepare_page', 'rest_page_query', 10, 3 );
function rest_page_query( $data, $post, $request ) {
$current_user = wp_get_current_user();
$html = '';
$html .= 'Username: ' . $current_user->user_login . '<br />';
$html .= 'User email: ' . $current_user->user_email . '<br />';
$html .= 'User first name: ' . $current_user->user_firstname . '<br />';
$html .= 'User last name: ' . $current_user->user_lastname . '<br />';
$html .= 'User display name: ' . $current_user->display_name . '<br />';
$html .= 'User ID: ' . $current_user->ID . '<br />';
$data->data['content']['rendered'] = $html;
return $data;
}
This solution it is not ideal, but it can works. So my questin is, there is some option to get simple url "/profile/"
Thx :)