Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 4 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
add comment

Your Answer

 
discard

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.