• Hi! I would like to know if there is a way to redirect a custom page in my menu to another page based on a purchased WooCommerce product for logged in customers. I want to create a page ‘My course’ and place it in the menu and show it only to customers who are logged in. Once a user purchases a course on the website and logs in and once they click on that page in the menu, they should be redirected to the specific course they purchased. So if they purchased a product A, they should be redirected to page A, if they purchased a product B, they should be redirected to page B if they click on that page in the menu.

    Is there a way to do this with PHP?

    Thanks for any direction and help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Well, if they have to go to a specific course page based on their purchase, then by definition, that’s not a “random” page 😀

    Also, the redirection is one thing… but what about security? How does the course platform “know” that this user has purchased the course and should be granted access (after clicking the appropriate link)?

    What are you using for your “courses” anyway? Is it a WordPress plugin or theme? Or is it an external course platform/software?

    It sounds like what you really need is to integrate your WooCommerce store with the platform/plugin/theme you’re using for the courses… so that IF someone makes a WooCommerce purchase, THEN they’re granted access to the corresponding course(s).

    So if they purchased a product A, they should be redirected to page A, if they purchased a product B, they should be redirected to page B if they click on that page in the menu.

    What happens if they purchase products A and B? 😀

    You probably want to have a common “My Courses” page. But, on this page, users will find linked cards (titles + thumbnails) to the course(s) they’ve purchased.

    You could even list or recommend other courses on this “My Courses” — users will see these courses, but when they click to access, they’ll be directed to the sales or checkout page to purchase them.

    Thread Starter anaitboyajyan

    (@anaitboyajyan)

    Hi,

    Thanks for replying 🙂 To answer your question, the page of the course is kind of ‘linked’ to the product in a sense that I am using a plugin that only enables customers who purchased that course product to view the course, so in that sense it is protected.

    The solution you are saying would be ideal (to have ‘My Courses’ page that would list one or more of their purchased courses that they can access).

    Do you maybe have a suggestion on how to show these purchased courses / products on this page? Is it best to do it through PHP snippets?

    Thanks a lot again!

    Do you maybe have a suggestion on how to show these purchased courses / products on this page?

    That should be something natively provided by the tool you’re using for the courses.

    What are you using to run the courses?

    Hi,

    You need to add condition using particular menu IDs or slug based using hooks If user is logged in then menu will so other wise hidden.

    There is many plugins avaible to show and hide menu based on condition like: https://wordpress.org/plugins/if-menu/ so you can try.

    Moderator bcworkz

    (@bcworkz)

    (to have ‘My Courses’ page that would list one or more of their purchased courses that they can access).

    I recommend a custom page template to manage this page’s content. This is more than PHP snippets. It’s complete PHP/HTML code in a new template file. Custom templates like this are best kept in a child theme.

    Note that this is not a “redirect” per se, it’s a direct link from menu to page. It’s not that important that users with no purchased products see such a menu link, the page could simply show them available products or direct them to the general shop page. The page template can determine if the current user is logged in and if they’ve purchased anything. If not, show them certain generic content. If so, query for what they’ve purchased and show it to them. Exactly how depends on how product purchases are managed, but if it’s available in the DB somewhere, there’s a way to get the appropriate data and display it.

    To be clear, this is a single, dynamic page for everyone, but specifically what a user sees will vary from user to user. There’s no need to redirect to somewhere else based on some conditions, it’s all managed locally by one page’s template code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.