Wordpress filter Vs. action -


i have code in functions.php can see below. when hook in using action function doesn't execute, when hook filter does, explain why , whats best practice?

action

// add £40 on succesful subscription payment (example 1) function custom_add_funds($user_id) {      // current user's funds     $funds = get_user_meta( $user_id, 'account_funds', true );      // add £40     $funds = $funds + 40;      // add funds user     update_user_meta( $user_id, 'account_funds', $funds );  } add_action('processed_subscription_payment', 'custom_add_funds'); 

filter

// add £40 on succesful subscription payment (example 2) function custom_add_funds_two($user_id) {      // current user's funds     $funds = get_user_meta( $user_id, 'account_funds', true );      // add £40     $funds = $funds + 40;      // add funds user     update_user_meta( $user_id, 'account_funds', $funds );  } add_filter('processed_subscription_payment','custom_add_funds_two'); 

both functions have different functionalities. actions event based. suppose want call function after submitting form or page load in case use add_action function.

whereas filters used change current flow. page have content "hello test content", , want show "hello world yours test content" use filters.

for further details can see following links:

difference between add_filter versus add_action https://wordpress.stackexchange.com/questions/120339/difference-between-do-action-and-add-action


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -