Created
April 17, 2026 13:48
-
-
Save andrewlimaza/dc5616dabfae0562c4f33728876274f6 to your computer and use it in GitHub Desktop.
PMPro update PayPal Webhook ID value for the new PayPal gateway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Adjust the PMPro PayPal gateway webhook ID to point to a new webhook that was manually created. | |
| * Run this in your browser once yoursite.com/wp-admin/?pp_webhook_id=12345 | |
| * Delete this snippet when no longer needed. | |
| * | |
| * Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| add_action( 'admin_init', function() { | |
| if ( ! isset( $_GET['pp_webhook_id'] ) ) { | |
| return; | |
| } | |
| if ( ! current_user_can( 'manage_options' ) ) { | |
| wp_die( 'Unauthorized' ); | |
| } | |
| $environment = get_option( 'pmpro_gateway_environment', 'sandbox' ); | |
| $suffix = 'sandbox' === $environment ? '_sandbox' : '_live'; | |
| $option_name = 'pmpro_paypal_webhook_id' . $suffix; | |
| $new_webhook_id = sanitize_text_field( $_GET['pp_webhook_id'] ); | |
| update_option( $option_name, $new_webhook_id ); | |
| wp_die( sprintf( | |
| 'Webhook ID updated. <strong>%s</strong> set to: <code>%s</code>', | |
| esc_html( $option_name ), | |
| esc_html( $new_webhook_id ) | |
| ) ); | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment