WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the latest version of wp-ecommerce (3.89) and a new filter has been introduced to enable role based access to certain dashboard features such as the sales page or upgrade capability. However, the default role in the core file is currently set to "administrator".

What I would like to do is take the original filter and modify it by placing the modified code in my functions file to over-ride that.

So how to modify this: (from plugin file wp-ecommerce/wpsc-admin/admin.php

$purchase_logs_cap = apply_filters( 'wpsc_purchase_logs_cap', 'administrator' );
$page_hooks[] = $purchase_logs_page = add_submenu_page( 'index.php', __( 'Store Sales', 'wpsc' ), __( 'Store Sales', 'wpsc' ), $purchase_logs_cap, 'wpsc-purchase-logs', 'wpsc_display_purchase_logs_page' );

to something like this

remove_filter('wpsc_purchase_logs_cap', 'administrator');
function sh_wpsc_admin_pages($purchase_logs_cap) {
apply_filters( 'wpsc_purchase_logs_cap', 'editor' );

share|improve this question
up vote 5 down vote accepted

The filter exists to avoid the need for replacements in the plugin code.

What you probably need is:

add_filter( 'wpsc_purchase_logs_cap', 'wpse_72095_admin_to_editor' );

function wpse_72095_admin_to_editor()
    return 'edit_others_posts';

This will change the capability/role to editor.

share|improve this answer
Ah that was it, thank you. I couldn't quite get the syntax ! – Sol Nov 10 '12 at 3:16
Hmmm it seems that although this now give access to the editor, it also removes access for the administrator. Is it possible to define both ? – Sol Nov 10 '12 at 4:22
It is better to ask for a real capability than for a role. I changed the sample code. – toscho Nov 10 '12 at 4:27
Doh - why didn't I think of that! Thanks dude. – Sol Nov 10 '12 at 4:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.