Last active
November 19, 2020 09:35
-
-
Save ipokkel/207582cf76353f6336d6b1804af7d1d8 to your computer and use it in GitHub Desktop.
Add a "Buy Gif Level" on the account page for member action links #gift #pmpro-gift-levels
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 | |
/** | |
* This recipe adds a "Buy Gif Level" for the first gift level | |
* defined in the pmprogl_gift_levels array to the PMPro | |
* member action links on the PMPro account page. | |
* | |
* This recipe assumes that only one gift giving level exist. | |
* You or your developer may expand on this example recipe when | |
* there is more than one gift level. | |
* | |
* 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_member_action_link_gifting( $pmpro_member_action_links ) { | |
global $pmprogl_gift_levels; | |
if ( function_exists( 'pmprogl_pmpro_after_checkout' ) && ! empty( $pmprogl_gift_levels ) || count( $pmprogl_gift_levels ) >= 0 ) { | |
$pmpro_member_action_links['gift'] = '<a href="' . pmpro_url("checkout", "?level=" . array_key_first( $pmprogl_gift_levels ), 'https') . '">Buy Gift Level</a>'; | |
} | |
return $pmpro_member_action_links; | |
} | |
add_filter( 'pmpro_member_action_links', 'my_pmpro_member_action_link_gifting' ); |
Author
ipokkel
commented
Nov 19, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment