Skip to content

Instantly share code, notes, and snippets.

Avatar

Theuns Coetzee ipokkel

View GitHub Profile
View pmpro_block_dashboard-grant-certain-user-roles.php
<?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' ) ) {
View my_init_override_sponsored_members_pricing_update.php
<?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.
@ipokkel
ipokkel / readonly-on-profile-page-registration-field.php
Last active Mar 24, 2022
Set a custom registration field for PMPro Register Helper as readonly on the profile edit page.
View readonly-on-profile-page-registration-field.php
<?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.
@ipokkel
ipokkel / wp-mail-log.php
Last active Mar 10, 2022
Debugging email for WordPress. Logs mail erorrs,
View wp-mail-log.php
<?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
@ipokkel
ipokkel / add-required-html-attribute.php
Last active May 9, 2022
Add required HTML attribute to required fields on PMPro Checkout Page.
View add-required-html-attribute.php
<?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/
*/
@dparker1005
dparker1005 / load-pmpro-stripe-library.php
Last active Feb 24, 2022
Make sure that PMPro loads the Stripe library first if other plugins are loading outdated versions on every page load.
View load-pmpro-stripe-library.php
<?php
/**
* Make sure that PMPro loads the Stripe library first if other plugins are loading outdated
* versions on every page load. This is a blunt way to address the conflict and should be used
* with caution.
*
* To use, add as a new file in your site's `wp-content/mu-plugins/` folder.
*/
if ( file_exists( dirname( __FILE__ ) . "/../plugins/paid-memberships-pro/includes/lib/Stripe/init.php" ) && ! class_exists( "Stripe\Stripe" ) ) {
@andrewlimaza
andrewlimaza / clear-stripe-level-meta.php
Created Feb 16, 2022
Clear Stripe level meta data [Script]
View clear-stripe-level-meta.php
<?php
/**
* Clear any unnecessary Stripe data from level meta table that may be causing checkout issues.
*
* To run this code add it to your WordPress website by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Once installed, add ?clean_stripe=1 to any URL while logged-in as an admin.
*
* After running this script, please delete it from your site.
*
* @return void
@kimwhite
kimwhite / my-pmpro-addon-package-access.php
Last active Jan 25, 2022
Give access to specific Addon Packages by Level
View my-pmpro-addon-package-access.php
<?php // do not copy this line.
/**
* Give user's with a certain level ID 4 free access to all some Addon Packages content.
*
* 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/
*/
@andrewlimaza
andrewlimaza / pmpro-addon-packages-woocommerce.php
Last active Jan 25, 2022
Add or Remove Addon Package access based on WooCommerce purchased products.
View pmpro-addon-packages-woocommerce.php
<?php
/**
* Integrate Addon Packages with WooCommerce product purchased (based on the order status).
* Recommended to be used with PMPro WooCommerce to apply a default level for all products that give access to posts (Addon Packages).
*
* To get started, please adjust the $product_ids_to_posts global array which uses a product_id => post_id key/value pair.
* Extend this array for all products that will give access to posts.
*
* Adds access to the post once the order is completed.
* Removes access from the post if the order is set to cancelled, failed or refunded.
View mypmpro-autofill-checkout-fields-woocommerce.php
<?php //do not copy
/**
* This recipe will automatically populate the PMPro checkout fields Woocommerce field data.
*
* 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/
*/