Skip to main content
typo.
Source Link
Fayaz
  • 9k
  • 2
  • 32
  • 51

You can simply use the same filter with a lower or higher prioritya lower or higher priority parameter to make the appropriate changes to the $actions array. That way you may create a small custom plugin (or modify the theme's functions.php file), without having to modify the existing plugin directly.

IfFor example: if you want your custom code to execute after add_edit_address_subscription_action function, then use a bigger priority argument (lowlower priority), and if you want your custom code to execute beforethe add_edit_address_subscription_actionwcs_view_subscription_actions function, then use a smaller priority argument (high priority)filter.

Sample CODE (use this as part of a custom plugin or in your theme's functions.php file):

add_filter(// 'wcs_view_subscription_actions',original 'wpse_custom_action_before',filter 9uses priority 10, 2so );priority 11 will make sure that this function executes after the original implementation
add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_after', 11, 2 );

function wpse_custom_action_beforewpse_custom_action_after( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed beforeafter add_edit_address_subscription_action function 
    return $actions;
}

On the other hand, if you want your custom code to execute before add_edit_address_subscription_action function, then use a smaller priority argument (higher priority).

Sample CODE (use this as part of a custom plugin or in your theme's functions.php file):

// original filter uses priority 10, so priority 9 will make sure that this function executes before the original implementation
add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_before', 9, 2 );    
function wpse_custom_action_afterwpse_custom_action_before( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed afterbefore add_edit_address_subscription_action function 
    return $actions;
}

You can simply use the same filter with a lower or higher priority to make the appropriate changes to the $actions array.

If you want your custom code to execute after add_edit_address_subscription_action function, then use a bigger priority argument (low priority), and if you want your custom code to execute before add_edit_address_subscription_action function, then use a smaller priority argument (high priority).

Sample CODE (use this as part of a custom plugin):

add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_before', 9, 2 );
add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_after', 11, 2 );

function wpse_custom_action_before( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed before add_edit_address_subscription_action function 
    return $actions;
}

function wpse_custom_action_after( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed after add_edit_address_subscription_action function 
    return $actions;
}

You can simply use the same filter with a lower or higher priority parameter to make the appropriate changes to the $actions array. That way you may create a small custom plugin (or modify the theme's functions.php file), without having to modify the existing plugin directly.

For example: if you want your custom code to execute after add_edit_address_subscription_action function, then use a bigger priority argument (lower priority) to the wcs_view_subscription_actions filter.

Sample CODE (use this as part of a custom plugin or in your theme's functions.php file):

// original filter uses priority 10, so priority 11 will make sure that this function executes after the original implementation
add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_after', 11, 2 );

function wpse_custom_action_after( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed after add_edit_address_subscription_action function 
    return $actions;
}

On the other hand, if you want your custom code to execute before add_edit_address_subscription_action function, then use a smaller priority argument (higher priority).

Sample CODE (use this as part of a custom plugin or in your theme's functions.php file):

// original filter uses priority 10, so priority 9 will make sure that this function executes before the original implementation
add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_before', 9, 2 );    
function wpse_custom_action_before( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed before add_edit_address_subscription_action function 
    return $actions;
}
Source Link
Fayaz
  • 9k
  • 2
  • 32
  • 51

You can simply use the same filter with a lower or higher priority to make the appropriate changes to the $actions array.

If you want your custom code to execute after add_edit_address_subscription_action function, then use a bigger priority argument (low priority), and if you want your custom code to execute before add_edit_address_subscription_action function, then use a smaller priority argument (high priority).

Sample CODE (use this as part of a custom plugin):

add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_before', 9, 2 );
add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_after', 11, 2 );

function wpse_custom_action_before( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed before add_edit_address_subscription_action function 
    return $actions;
}

function wpse_custom_action_after( $actions, $subscription ) {
    // your custom changes to $actions array HERE
    // this will be executed after add_edit_address_subscription_action function 
    return $actions;
}