Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • in reply to: Grant access to dashboard for specific roles/users #107279
     verloren
    Participant

    Instead of removing the action, it’s better to add a filter which hooks into “prevent_admin_access”.
    Here an example:

    COPY CODE
    
    add_filter(‘woocommerce_prevent_admin_access’, ‘preventAdminAccess’);
    
    function preventAdminAccess() {
    $prevent = false;
    
    if (userShouldNotSeeDashboard()) {
    $prevent = true;
    }
    
    return $prevent;
    }
    

    Best regards.

    in reply to: Grant access to dashboard for specific roles/users #107278
     verloren
    Participant

    Instead of removing the action, it’s better to add a filter which hooks into “prevent_admin_access”.
    Here an example:

    `
    add_filter(‘woocommerce_prevent_admin_access’, ‘preventAdminAccess’);

    function preventAdminAccess() {
    $prevent = false;

    if (userShouldNotSeeDashboard()) {
    $prevent = true;
    }

    return $prevent;
    }

    Best regards.

    in reply to: Grant access to dashboard for specific roles/users #107273
     verloren
    Participant

    Hi all,

    found it.

    In /wp-content/plugins/woocommerce/includes/admin/class-wc-admin.php is function “prevent_admin_access”. Here the docblock:

    COPY CODE
    
    /**
      * Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from accessing admin.
      */
    

    Within class-wc-admin.php constructor, the action is added:

    COPY CODE
    
    public function __construct() {
      ...
      add_action( 'admin_init', array( $this, 'prevent_admin_access' ) );
    }
    

    So from here it’s easy to remove the action and add an own action.

    Best regards.

     verloren
    Participant

    Sorry for third post….

    Tried to deactivate state field with Booster Plus for WooCommerce. Deactivating the field has no effect. Trying to remove the required attribute (with this plugin) has no effect, too.
    State field is not my friend….

     verloren
    Participant

    I forgot to mention that sometimes it is impossible to order because of that. When i try to order without seeing preloaded data, there is no chance to submit a fully filled form.

    When changing country, state hides. So no way to fill it out.
    When trying to submit form, it gets reloaded with warning that state is a required field. But all other fields are empty now, too.
    Trying to fill it again ends up in a hidden state field.

Viewing 5 posts - 1 through 5 (of 5 total)

Log in with your credentials

Forgot your details?