wp_nonce_ays()
Display "The link you followed has expired" message with a link to the previous page - wp_get_referer().
No Hooks.
Return
null
. Nothing.
Usage
wp_nonce_ays( $action );
- $action(string) (required)
- If log-out then the message will be "You are attempting to log out of SiteName. Do you really want to log out?"
Examples
#1 Wrong link
If the current is wrong you can stop the further PHP execution with a message that the current link is expired:
global $wp; $current_url = home_url( $wp->request ); // if $current_url is illegal if( $current_url === "https://example.com/destroy/the/world" ){ wp_nonce_ays(); // stops PHP execution with a link to the previous page } else { // nice }
#2 Logout warning
If you want to warn a user before logout, you can use such code:
if( $_GET['logout'] ){ wp_nonce_ays( 'log-out' ); }
Changelog
Since 2.0.4 | Introduced. |