Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dwanjuki/b8ffd03a04ce46a379d451039e857321 to your computer and use it in GitHub Desktop.
Save dwanjuki/b8ffd03a04ce46a379d451039e857321 to your computer and use it in GitHub Desktop.
Add a shortcode to show the currently active PMPro affiliate code
<?php
/**
* Add a shortcode to show the currently active PMPro affiliate code
*
* Use shortcode: [show_affiliate_code]
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_show_affiliate_code() {
$code = $_COOKIE['pmpro_affiliate'] ?? '';
return $code;
}
add_shortcode( 'show_affiliate_code', 'my_pmpro_show_affiliate_code' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment