Must exist a real page in WordPres?
Yes, you need to create a page, but it doesn’t have to have any content.
Let’s say you created a new page named ‘Confirmation message’. The URL would be http://example.com/confirmation-message
.
Now add the following to the functions.php
of your theme:
/**
* Adds a confirmation message to the content of a page.
*
* @param string $content The current content of the page.
* @return string The new content of the page.
*/
function show_confirmation_message($content) {
// Don't add message if 'myplugin', 'confirmkey' and 'mail' are not in the URL.
if (!isset($_GET['myplugin']) || empty($_GET['confirmkey']) || empty($_GET['mail'])) {
return $content;
}
// Don't add message if we're not on a page and not in the main query.
if( !is_page() || !is_main_query() ) {
return $content;
}
// Add the logic to show a confirmaiton message here...
$content.= 'This is the confirmation message.';
return $content;
}
add_filter('the_content', 'show_confirmation_message');
Now, if you go to:
http://example.com/confirmation-message?myplugin&confirmkey=KEY&mail=MAIL
you should see the confirmation message.