Feature to prevent admin access to customers (optional). Closes #228.

This commit is contained in:
Mike Jolley 2011-11-18 14:31:53 +00:00
parent a448406787
commit 74fd322230
3 changed files with 25 additions and 0 deletions

View File

@ -136,6 +136,14 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
'type' => 'checkbox',
),
array(
'name' => __( 'Admin access', 'woothemes' ),
'desc' => __( 'Prevent customers from accessing WordPress admin', 'woothemes' ),
'id' => 'woocommerce_lock_down_admin',
'std' => 'no',
'type' => 'checkbox'
),
array(
'name' => __( 'Shop Styling', 'woothemes' ),
'desc' => __( 'Enable WooCommerce CSS styles', 'woothemes' ),

View File

@ -91,6 +91,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Made record_product_sales trigger once only
* Payment complete only when on-hold/pending
* More logging in paypal gateway
* Feature to prevent admin access to customers (optional)
= 1.2.3 - 17/11/2011 =
* Fix for sale price logic

View File

@ -4,6 +4,7 @@
*
* Actions/functions/hooks for WooCommerce related events.
*
* - Prevent non-admin access to backend
* - Update catalog ordering if posted
* - AJAX update shipping method on cart page
* - AJAX update order review on checkout
@ -27,6 +28,21 @@
* @author WooThemes
*/
/**
* Prevent non-admin access to backend
*/
if (get_option('woocommerce_lock_down_admin')=='yes') add_action('admin_init', 'woocommerce_prevent_admin_access');
function woocommerce_prevent_admin_access() {
if ( is_admin() && !is_ajax() && !current_user_can('edit_posts') ) :
wp_safe_redirect(get_permalink(get_option('woocommerce_myaccount_page_id')));
exit;
endif;
}
/**
* Update catalog ordering if posted
*/