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 //do not copy | |
/** | |
* This code snippet checks if there's more than one item in the cart, | |
* finds the cheapest product and discounts it from the cart's total. | |
*/ | |
function buyone_getone_free_discount() { | |
$contents = edd_get_cart_contents(); |
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 //do not copy | |
/** | |
* Gets the next payment date and marks that as the expiration date for users. | |
* | |
* The "next payment" value is an estimate based on the billing cycle of the subscription and the last order date. It may be off from the actual recurring date set at the gateway, especially if the subscription was updated at the gateway. | |
* | |
* Remove the // on line 40 to run the update query. | |
* | |
* You can add this recipe to your site by creating a custom plugin |
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
# PMPro doesn't set the character set when creating its tables. | |
# So on install PMPro will use the default character set for your DB. | |
# In some cases this might be something like latin1, which will not | |
# work with special characters for non-latin languages, e.g. Hebrew. | |
# To fix this, you can update the character set on these tables using MySQL. | |
# | |
# IMPORTANT: Back up your DB (at least these tables) before running any queries. | |
ALTER TABLE wp_pmpro_membership_levels CONVERT TO CHARACTER SET utf8; | |
ALTER TABLE wp_pmpro_membership_levelmeta CONVERT TO CHARACTER SET utf8; | |
ALTER TABLE wp_pmpro_membership_ordermeta CONVERT TO CHARACTER SET utf8; |
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 | |
/** | |
* This will add billing fields to the administrative user profile edit page for administrators | |
* and on the frontend PMPro user Edit Profile page for members. | |
* | |
* 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/ | |
*/ |
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 | |
/** | |
* Remove subscription delay for existing/past members. | |
*/ | |
function my_pmpro_remove_subscription_delay_for_renewals() { | |
if ( is_admin() || ! is_user_logged_in() ) { | |
return; | |
} | |
$order = new MemberOrder(); |
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 | |
/** | |
* Grant access to the back-end to certain user roles | |
* | |
* @param bool $prevent_admin_access | |
* | |
* @return bool | |
*/ | |
function pmpro_grant_admin_access_to_dataanalyst( $prevent_admin_access ) { | |
if ( current_user_can( 'dataanalyst' ) ) { |
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 // do not copy this line. | |
/** | |
* Sponsored Members setup with child seat costs at checkout. | |
* SPONSOR SEAT + 4 seats 19.95 each | |
* + 5 to 19 @ 17.95 | |
* + 20 to 39 @ $15.95 | |
* + 40 to 79 @ 14.95 | |
* | |
* 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. |
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 | |
/** | |
* Readonly field on profile edit page. | |
* | |
* Add profile_readonly to field and set to true. | |
* | |
* Fields with this option will remain editable if the field is empty, or | |
* if the current user can manage options (administrators), or | |
* if the current user is a membership manager that have a | |
* membership manager role. |
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 | |
/** | |
* WordPress Mail Debugger | |
* | |
* Log mail error message to debug-mail.log in wp-contents folder. | |
* Log mail error to debug.log in wp-contents folder. | |
*/ | |
function wp_mail_error_log( $wp_error ) { | |
// Log mail error message to debug-mail.log file in wp-contents folder |
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 | |
/** | |
* Add HTML5 attribute required to all required PMPro fields. | |
* | |
* 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/ | |
*/ |