• Hi,

    Not sure if this is the place to ask but here goes.

    I have WP e-Commerce and wish to override a add menu function they have in it using my own code.

    I already know how to do this and what code to use. My issue now is that by editing the original file in the plugin, if I update WPEC then I need to make that edit again.

    Is there a way to override or replace it with my own using another plugin?

    I want to write a plugin that makes the change I am needing so that I can update WPEC and all should be good until they change the code I replace.

    Also new to writing plugins so I would prefer to be pointed in the right direction if its possible so I can learn for myself how to do it.

    PS: the code I am wanting to change is this:

    $page_hooks[] = $purchase_log_page = add_submenu_page( ‘index.php’, __( ‘Store Sales’, ‘wpsc’ ), __( ‘Store Sales’, ‘wpsc’ ), ‘administrator’, ‘wpsc-sales-logs’, ‘wpsc_display_sales_logs’ );

    to this:

    $page_hooks[] = $purchase_log_page = add_submenu_page( ‘index.php’, __( ‘Store Sales’, ‘wpsc’ ), __( ‘Store Sales’, ‘wpsc’ ), ‘wpsc_sales_logs’, ‘wpsc-sales-logs’, ‘wpsc_display_sales_logs’ );

    Its a simple change that works the way I need it to, but I have to start somewhere with plugin writing right.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The way I see it, you’ve got 3 options:

    1. Edit the plugin files to achieve your desired result. If you update later, you’d have to update your change.
    2. Write a simple plugin using the Writing a Plugin Codex page as a template. This is the best option, because it won’t break your site if your code can’t execute properly, it’ll only disable the plugin.
    3. You could try editing your theme’s functions.php file to override the action. Be very careful though. Make sure you have the ability to access your theme’s files via FTP before making any changes to the functions.php file, because if you induce a syntax error or there is any problem with the code you entered, you’re going to break your site. If you break it, you can then reverse the changes via downloading your functions.php file via FTP and removing the offending code. Proceed with caution.

    Hope that helps.

    Thread Starter Shaun Williams

    (@eangulus)

    That kinda helps. I knew the first 2 options but didn’t know the 3rd. I did think I can override another plugin from the functions file.

    My preference is as a plugin. Maily cause it will be on a multisite setup and the Vance I want will be required on all my sites.

    My question is thou how do I make sure my mod is executed after WPEC? Cause obviously I don’t want WPEC to override my changes.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Override an action using a plugin.’ is closed to new replies.