modify a function filter

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.

Read More

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' );

}

Related posts

Leave a Reply

1 comment

  1. 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.