Support » Plugin: Advanced Access Manager » WooCommerce Pages Redirection

  • Resolved leobr


    I’m trying to redirect the “Shop” page of the WooCommerce plugin to another page (page “B” for simplicity) of my site. It is possible to do this by WooCommerce itself, but I do not want to lose the formatting of page “B”.
    While using the AAM and entering the correct page ID “B”, redirection of the “Shop” page to page “B” is not occurring.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi leobr,

    To redirect shop page to B page (I assume that slug is “b” for B page i.e. put following code into your child theme’s functions.php

    //Redirecting shop url to B page
    add_filter( ‘woocommerce_return_to_shop_redirect’, “custom_woocommerce_return_to_shop_redirect” ,20 );
    function custom_woocommerce_return_to_shop_redirect(){
    return site_url(‘/b’);

    Hope this will help you.

    Plugin Author Vasyl Martyniuk


    Hi @leobr,

    Unfortunately AAM does not play well with WooCommerce Shop page because for some reason WooCommerce core developers define this page as “archive” and technically that page simply does not exist as solid page but rather as a container for Products. That is why AAM cannot read Shop page access settings because it does not exist.

    You might follow @dineshinau advice. It is not the best solution but it might work pretty well.


    Hi @leobr, @dineshinau and @vasyltech,

    I encounter a similar problem using AAM with Woocommerce extension.
    Here are modifications proposals that worked for me.

    @vasyltech, can you tell me if this code can produce some bugs/problems ? Especially for is_tax() call addition that may be added in the official source code ?

    First step : “Plus Package Extension” allow to manage access to categories. In Woocommerce, this can be useful to hide some product categories to the user. However, Woocommerce use custom taxonomy for product category and this is not managed by AAM as “is_category” function is used to check the capability to restrict access.
    We need to add a call to “is_tax” method to manage custom post types.
    In plus-package/Frontend.php, line 58, replace :
    if (is_category()) {
    With :
    if (is_category() || is_tax()) {

    Second step : As @vasyltech write, Woocommerce use a “strange” method to manage the shop page that do not raise a call to AAM. This can be bypassed by checking the location of the user ton page display and manually call AAM if user is on the shop page.

    Here is the code to add in a your custom functions :
    function wpse_131562_redirect() {

    if (is_plugin_active(“advanced-access-manager/aam.php”) &&
    class_exists(‘AAM’) && class_exists(‘AAM_Frontend_Authorization’)
    && is_plugin_active(“woocommerce/woocommerce.php”) && function_exists(‘is_shop’)) {
    if (is_shop()) {
    $user = AAM::getUser();

    $post = $user->getObject(‘post’, wc_get_page_id( ‘shop’ ));

    if ($post) {
    } else {
    $to = get_bloginfo(‘admin_email’);
    $subject = get_bloginfo(‘name’) . ‘ : Security Breach’;
    $message = ‘Advanced Access Manager/Woocommerce have been disabled or the behavior/name of its classes have been modified.
    Link between AAM and Woocommerce is broken.’;

    wp_mail( $to, $subject, $message );

    add_action(‘template_redirect’, ‘wpse_131562_redirect’);

    Note that mail sending is not mandatory. I use it to manage plugin update which would break this function behavior.

    Hope this will helps,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WooCommerce Pages Redirection’ is closed to new replies.