Hooks & Filters
Below is a detailed description of the hooks and filters available in the Payment Page plugin, tailored for advanced developers. Each hook and filter includes its name, purpose, and usage examples.
Action Hooks
add_action('payment_page_after_payment', 'log_payment_details', 10, 2); function log_payment_details($transaction_id, $amount) { // Log the transaction details error_log("Transaction processed. ID: $transaction_id, Amount: $amount"); }
add_action('payment_page_settings_saved', 'clear_cache_after_settings_change'); function clear_cache_after_settings_change() { // Clear cached data after settings are updated my_cache_clear_function(); }
add_action('payment_page_gateway_initialized', 'check_gateway_configuration'); function check_gateway_configuration($gateway) { // Check if gateway configuration is correct if (!isset($gateway['api_key'])) { // Handle missing API key error_log("API key is missing for the gateway."); } }
add_action('payment_page_before_payment', 'validate_payment_request', 10, 1); function validate_payment_request($payment_data) { // Perform validation on payment data if ($payment_data['amount'] <= 0) { wp_die('Invalid payment amount.'); } }
add_action('payment_page_gateway_disabling', 'notify_gateway_disabling', 10, 1); function notify_gateway_disabling($gateway_name) { // Notify users when a gateway is disabled wp_mail('[email protected]', 'Gateway Disabled', "$gateway_name has been disabled."); }
Filter Hooks
Last updated