Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created April 17, 2026 13:48
Show Gist options
  • Select an option

  • Save andrewlimaza/dc5616dabfae0562c4f33728876274f6 to your computer and use it in GitHub Desktop.

Select an option

Save andrewlimaza/dc5616dabfae0562c4f33728876274f6 to your computer and use it in GitHub Desktop.
PMPro update PayPal Webhook ID value for the new PayPal gateway.
<?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