As a complimentary addition to Kaiser\'s answer you can secure things further by using a nonce value. (numbers used once)
Step 1 - create your link with nonce value
Page A (the referring page where your users are coming from)
<?php
$url = "http://example.com/destination-slug/";
$nonce_url = wp_nonce_url( $url, "secure_this_page_nonce");
echo "<a href=\'".$nonce_url."\'>Click me!</a>";
?>
This will create a link like,
http://example.com/destination-slug/?_wpnonce=8c9xa6e33e
Step 2 - verify the nonce value passed from link
Page B (where you users are going once they click the above link)
<?php
if (!wp_verify_nonce($_GET[\'_wpnonce\'],\'secure_this_page_nonce\')) {
//optionally redirect users back to the page you want them to come from
$previous_page = \'http://example.com/previous-page/\';
wp_redirect( $previous_page, 301)
exit;
} else {
//continue with normal processing of page
}
?>
This checks for the existence of a nonce via the $_GET parameter _wpnonce
and whether the action/name secure_this_page_nonce
is set which equates to this portion of the URL as shown in Step 1 ?_wpnonce=8c9xa6e33e
.
If the nonce value is not present and fails its conditional check then you can redirect the user back to the previous page.
If it passes the conditional check then the user has originated from clicking our link on Page A, in which case we render the page as normal.
Good luck!