Created
June 12, 2024 14:54
-
-
Save dwanjuki/b8ffd03a04ce46a379d451039e857321 to your computer and use it in GitHub Desktop.
Add a shortcode to show the currently active PMPro affiliate code
This file contains 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 | |
/** | |
* 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