We are developing a booking itinerary system, where a client can view a single post of their booking for the coming year. Each client will only ever have ONE custom post that they own.
We would like to create a 'conditional' redirect to the Home Page, in the event that a client manually changes their booking URL in an attempt to view someone elses booking - our booking references are sequentially numbered.
So, URL hidden link displays the clients booking, because they are logged in as user 221234
However if they change to this URL, hidden link I would like them to be redirected back to the home page
hidden link
We found this code:
function tssupp_redirect() {
if ( !is_user_logged_in() && is_page('inaccessible') ) {
wp_redirect(home_url());
exit;
}
}
add_action('template_redirect', 'tssupp_redirect');
However it is not redirecting in the way we want
Can you please help?
Kind regards
Ade
Hello,
How do you setup the relationship between "client" and "booking"?
"booking" post author is each "client" user?
Please provide more details for the questions.
Hi Luo
We have managed to sort the problem as follows:
<!-- wp:html -->
[wpv-conditional if=" ( ( '[wpv-current-user info='id']' ne '[wpv-post-author format='meta' meta='ID' ]' ) ) "]
<!-- /wp:html -->
<!-- wp:html -->
<div class="jump" id="details">
<p>You can only view your own booking for this years Open.</p></div>
<!-- /wp:html -->
<!-- wp:html -->
[/wpv-conditional]
<!-- /wp:html -->
<!-- wp:html -->
[wpv-conditional if=" ( ( '[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID' ]' ) ) "]
<!-- /wp:html -->
Kind regards
Ade
My issue is resolved now. Thank you!