Adds a short code which allows conditional output of page content based on the value of a token passed as a URL parameter or a POST variable
|Author:||Frank Culross (profile at wordpress.org)|
|WordPress version required:||4.7|
|WordPress version tested:||4.7.21|
|Added to WordPress repository:||21-03-2017|
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Click to start download
Page Guard uses a single URL parameter or POST variable as a means of providing a token to guard access to any page on which this plugin’s shortcode is placed. Output of alternative content can be made to occur when the token is missing or fails to match what is expected – if the token received matches the expected one, the controlled content can be revealed to the visitor.
The shortcode to use is ‘pageguard’ – its attributes are:
tokenparam (required) -> a string value containing the name of the token URL param - e.g. 'mytoken' eq (optional) -> a string value containing the expected value of the tokenparam - e.g. 'x34ggj45b' ne (optional) -> as for "eq" but when used, shortcode will output content on non matching token absent (optional) -> when absent="1", shortcode will output content on detection of missing token
show block on matching token - [pageguard param="token" eq="download"] Text to be output on matching token found [/pageguard] show block on non match - [pageguard tokenparam="token" ne="download"] Error text for output when token fails to match [/pageguard] show this on no token found - [pageguard tokenparam="token" absent="1"] Error text for output when token is missing [/pageguard]
A typical use scenario might be to control access to a downloads page. Suppose you have a PayPal “Buy Now” button on your site which allows visitors to make a payment for say, an eBook or audio recording. When setting up the button in your PayPal account you specify a URL on your site to which the visitor is returned after they’ve made payment. On this return page you’ve added a link the visitor can use to download their purchase – however, you don’t want any non paying visitors to have access to the download link(s) on the page!
Add a parameter to the end of the return URL (using any name and value you want) when you set up your button in PayPal e.g.
Next, add pageguard short codes for the cases you intend to handle to your return page in WordPress –
[pageguard param="token" eq="x34ggj45b"] Text to be output on matching token found [/pageguard] [pageguard tokenparam="token" ne="x34ggj45b"] Error text for output when token fails to match [/pageguard] [pageguard tokenparam="token" absent="1"] Error text for output when token is missing [/pageguard]
This will correctly display the main content for the page when Page Guard detects a matching token. It also provides for the possibility of providing different error content for the page in the event of the token being incorrect or missing.