Skip to content

Instantly share code, notes, and snippets.

View femiyb's full-sized avatar
🏠
Working from home

Samuel Femi Taiwo femiyb

🏠
Working from home
View GitHub Profile
@femiyb
femiyb / wp_head_hide_billing_fields.php
Last active March 25, 2019 17:35 — forked from strangerstudios/wp_head_hide_billing_fields.php
Hide Paid Memberships Pro billing address fields and make them optional. Meant to be used with the Braintree gateway.
/*
Hide billing address fields and make them optional.
Meant to be used with the Braintree Payments gateway.
*/
//css to hide the fields
function wp_head_hide_billing_fields()
{
global $post, $pmpro_pages;
if(empty($pmpro_pages) || (!is_page($pmpro_pages['checkout']) && !is_page($pmpro_pages['billing'])))
return;
@femiyb
femiyb / override-set-expiration-text.php
Created April 29, 2019 06:29 — forked from LMNTL/override-set-expiration-text.php
override expiration text for Set Expiration Date Add On for Paid Memberships Pro
/*
Change expiration text on levels page.
*/
function pmprosed_my_pmpro_level_expiration_text($expiration_text, $level)
{
$set_expiration_date = pmpro_getSetExpirationDate($level->id);
if (!empty($set_expiration_date)) {
$set_expiration_date = pmprosed_fixDate($set_expiration_date);
$expiration_text = "This membership level will expire on " . date(get_option('date_format'), strtotime($set_expiration_date, current_time('timestamp'))) . ".";
}
@femiyb
femiyb / rh_fields_example.php
Created May 3, 2019 16:20 — forked from andrewlimaza/rh_fields_example.php
Register Helper field type example shows an example of every possible field in Register Helper
<?php
/**
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it.
* For more information on the Register Helper Add-on please visit https://www.paidmembershipspro.com/add-ons/free-add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
**/
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
@femiyb
femiyb / remove_pmpro_billing_fields_by_level_id.php
Last active June 7, 2019 18:51 — forked from travislima/remove_pmpro_billing_fields_by_level_id.php
Remove Billing Address for certain Membership Levels
<?php
/* This code recipe will remove the billing address fields from certain membership levels.
* This code gist requires the Paid Memberships Pro - Capture Name & Address for Free Levels or for Off-site Gateways Add On to be installed and activated - https://www.paidmembershipspro.com/add-ons/capture-name-address-free-levels-offsite-gateway/
* Change the value "2" in the code recipe with the Paid Memberships Pro Membership Level ID of your choice.
* Add this code below into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function remove_pmpro_billing_fields_by_level_id() {
// Specify the Membership Level ID
$remove_level = isset( $_REQUEST['level'] ) ? $_REQUEST['level'] : '';
@femiyb
femiyb / pmpro-grace-period
Created June 25, 2019 11:29 — forked from andrewlimaza/pmpro-grace-period.php
PMPRO - Grace Period (After expiration date is met)
/*
* Add 15 day grace period when membership expires
*/
function my_pmpro_membership_post_membership_expiry( $user_id, $level_id ) {
// Make sure we aren't already in a grace period for this level
$grace_level = get_user_meta( $user_id, 'grace_level', true );
if ( empty( $grace_level ) || $grace_level !== $level_id ) {
// Give them their level back with 15 day expiration
$grace_level = array(1,2);
$grace_level['user_id'] = $user_id;
@femiyb
femiyb / pmpro_add_member_notification.php
Last active September 19, 2019 14:46 — forked from LMNTL/pmpro_add_member_notification.php
Generate checkout email when using Add Member from Admin Add On for Paid Memberships Pro
<?php
/* Generate checkout email when using Add Member from Admin Add On for Paid Memberships Pro
*/
function pmpro_send_member_notification( $user_id ) {
$pmproemail = new PMProEmail();
$pmproemail->sendCheckoutEmail( get_userdata( $user_id ) );
}
add_action( 'pmpro_add_member_added', 'pmpro_send_member_notification', 10, 2 );
@femiyb
femiyb / billing-fields-optional.php
Last active October 10, 2019 13:27 — forked from andrewlimaza/billing-fields-optional.php
Make billing details optional for Paid Memberships Pro
<?php
//add lines 4-15 to your custom plugin or functions.php of your active theme
function pmpro_remove_bfields( $pmpro_required_billing_fields ){
//remove field ID's from array to make fields required
$remove_field = array('bphone');
//loop through the $remove_field array and unset each billing field to make it optional.
foreach($remove_field as $field){
<?php
function my_pmpro_confirmation_url($rurl, $user_id, $pmpro_level)
{
if(pmpro_hasMembershipLevel(1))
$rurl = "http://example.com/page_1";
elseif(pmpro_hasMembershipLevel(2))
$rurl = "http://example.com/page_2";
elseif(pmpro_hasMembershipLevel(3))
$rurl = "http://example.com/page_3";
@femiyb
femiyb / pmpro-mailchimp-merge-fields-enddate.php
Created October 22, 2019 13:01 — forked from greathmaster/pmpro-mailchimp-merge-fields-enddate.php
Send the MERGE field enddate to MailChimp.
<?php
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user)
{
$level = pmpro_getMembershipLevelForUser($user->ID);
$enddate = date('Y-m-d', $level->enddate);
$new_fields = array("ENDDATE" => $enddate);
@femiyb
femiyb / pmpro_rh_checked_html_field.php
Created October 25, 2019 10:46
PMPro register helper pre-checked custom field example
<?php
//This code will be a full working example that will add 1 checkbox field to your checkout page for all levels. Please copy the code that you need.
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;