Skip to content

Instantly share code, notes, and snippets.

@hlashbrooke
Created June 26, 2013 12:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlashbrooke/5866863 to your computer and use it in GitHub Desktop.
Save hlashbrooke/5866863 to your computer and use it in GitHub Desktop.
Adding filter to woocommerce_prevent_admin_access()
function woocommerce_prevent_admin_access() {
$prevent_access = false;
if ( get_option('woocommerce_lock_down_admin') == 'yes' && ! is_ajax() && ! ( current_user_can('edit_posts') || current_user_can('manage_woocommerce') ) ) {
$prevent_access = true;
}
$prevent_access = apply_filters( 'woocommerce_prevent_admin_access', $prevent_access );
if( $prevent_access ) {
wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment