ADAMS_Project_Tutorials_How_To_Protect_Thank_You_Page_Feature_2_IMG_JPG

How to Protect WooCommerce Thank You Page from Direct Access

According to WIPO (World Intellectual Property Organization), Intellectual Property refers to the creation and labor of the mind, including its fruition. It could be inventions, artistic and literary works, symbols, names, images and designs used in commerce. So, when someone came up with an epic or novel artistic creations, it can be protected in various ways and in many levels. This can be Patents, Trademarks or Copyright. But what are they exactly and how are they any different?

In this tutorial, we’ll walk you through one of the simplest ways to protect your WooCommerce Thank You Page from direct access. This is an important step because the Thank You Page is intended exclusively for customers who have completed a checkout. Allowing unrestricted access to this page can pose security risks or create confusion.

Remember that this is not the only way to protect a page from direct access. There are a lot more ways to do it, especially when you’re using WordPress, WooCommerce and Elmentor Pro.

Why Protect the Thank You Page?

When you create a WordPress page, it’s publicly accessible by default. Anyone with the page URL can view it. To maintain the integrity and privacy of your store, we need to restrict access to the Thank You Page so that only legitimate customers can view it.

ADAMS Project Tutorials How To Protect Thank You Page IMG JPG

Assumptions

This tutorial assumes:

Method Overview

We’ll achieve this protection by:

Create and Customize Your Thank You Page

ADAMS Project Tutorials How To Protect Thank You Page Function PHP 2 IMG JPG

Add Custom Code to Your Theme

				
					/* Protect Thank You Page from Direct Access */
function redirect_thank_you_page() {
    if (is_page('thank-you')) { // Replace 'thank-you' with your page slug
        if (!isset($_GET['key'])) {
            wp_redirect(home_url());
            exit;
        }
    }
}
add_action('template_redirect', 'redirect_thank_you_page');

function custom_thank_you_redirect($order_id) {
    $order = wc_get_order($order_id);
    $order_key = $order->get_order_key();
    $thank_you_page_url = home_url('/thank-you/?key=' . $order_key); // Replace 'thank-you' with your page slug
    wp_redirect($thank_you_page_url);
    exit;
}
add_action('woocommerce_thankyou', 'custom_thank_you_redirect');

				
			
ADAMS Project Tutorials How To Protect Thank You Page Function PHP IMG JPG

QUICK NOTES:

Change or update the details in the code if necessary. Replacing the Thank You page slug with the one you have. You may just have ‘thank-you’ or ‘thank-you-page’ slug.

Slug is your page file name – all lower cases with followed with dashes. Also, the code executes a redirect to the homepage after direct access, you can update that as well.

Test Configuration

You should be redirected to the homepage (or the location you specified).

PRO TIP:

Use a child theme for customizations to avoid losing changes when the parent theme is updated.

Additional Considerations

By following these steps, you can safeguard your WooCommerce Thank You Page and ensure that it is accessed only by legitimate customers after completing a checkout. This approach combines simplicity and effectiveness, making it a great solution for most WooCommerce stores.

SHARE

RELATED POSTS

ADAMS_Project_Tutorials_How_To_Super_High_Resolution_Search_Google_Feature

How to Do Super High Resolution Image Search with Google

Gone are the days where you can still deliberately narrow up your image size search with Google. Today, image size searches have been singled-out by Google into just Any Size, Large, Medium and Icon. There will be no way for you to input image size numerically.

Read More
ADAMS_Project_Blog_3_Main_Tenets_UX_Design_Feature

3 Main Tenets of UX Design

In today’s fast-paced world, users have high expectations for the products and services they use. They want them to be easy to use, fast, and fun. This is where UX Design comes in.

UX Design, or User Experience Design, is the process of creating products and services that are easy to use, efficient, and enjoyable.

Read More
ADAMS_Project_Tutorials_Compressing_JPEG_Files_Feature

How to Compress JPEG Files without Losing Quality

In the digital age, images play a pivotal role in communication and content creation. However, large image files can quickly consume storage space and hinder website performance. JPEG, a commonly used image format, offers a balance between image quality and file size. However, compressing JPEG files often results in a noticeable loss of image quality.

Read More

COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *

SEARCH

ADAMS_Project_Mail_View_Sent_Icon_

Subscribed!

Thank you! Get it first and right. Rest assured of the latest news from us.

ADAMS_Project_Mail_View_Sent_Icon_

Message request sent!

Thank you!

Rest assured that your information is treated with utmost care and confidentiality as we want same thing done unto us.

Our reply to your message will be darting towards you at the speed of light!

ADAMS_Project_Mail_View_Sent_Icon_

Quote request sent!

Thank you!

Rest assured that your information is treated with utmost care and confidentiality as we want same thing done unto us.

Your custom quote will be darting towards you at the speed of light!