skip to Main Content

Administrator user can only customize themes. I am using wp_set_auth_cookie() for auto login and I don’t need any other admin pages.
When theme customize, administrator user details showing in my account page. Is it possible to restrict administrator login in WooCommerce my account page?

add_action( 'wp_loaded', 'my_theme_customization' );

function my_theme_customization()
{
    global $pagenow;
    if ($pagenow !== 'customize.php' && is_admin()) {
        header('Location:' . site_url());
        exit;
    }
}

enter image description here

2

Answers


  1. I think you can achieve it something like

    function iconic_login_redirect( $redirect, $user ) {
        if ( check user permissions ) {
            //redirect the admin to another page 
        }
    
    }
    
    add_filter( 'woocommerce_login_redirect', 'iconic_login_redirect' );
    

    I am not using wordpress from last 2 years, so you may like to look into line 1005 of woocommerce/includes/class-wc-form-handler.php

    Login or Signup to reply.
  2. I understand you should not mess with administrator privileges. Instead, you can create new user type with access as you want, and assign it to respective users.

    You can create new user type under Users –> Capabilities in WordPress admin page.

    Hope this will help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search