Skip to content

Instantly share code, notes, and snippets.

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

Femi YB femiyb

🏠
Working from home
View GitHub Profile
@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 / require_discount_code.php
Last active November 13, 2019 19:23
Require discount code on checkout
<?php
function my_pmpro_registration_checks_require_code_to_register($pmpro_continue_registration)
{
//only bother if things are okay so far
if(!$pmpro_continue_registration)
return $pmpro_continue_registration;
//level = 4 and there is no discount code, then show an error message
global $pmpro_level, $discount_code;
@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 / allow_access_to_wp_admin_wc.php
Created June 27, 2019 10:28
Allowing customer access to WP Admin if WooCommerce is active
/**
* Allow customers to access wp-admin
*/
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
add_filter( 'woocommerce_disable_admin_bar', '__return_false' );
<html>
PMPro Free (<a href="http://pmpro.local/wp-admin/admin.php?page=pmpro-approvals&s=user06%40pmpro.local">Pending</a>)
</html>
<p>Menu</p>
<nav>
<ul>
<p>Menu</p>
<?php
function my_pmpro_disable_member_emails($recipient, $email)
{
$user = get_user_by('login', $email->data['user_login']);
$level = pmpro_getMembershipLevelForUser($user->ID);
$disabled_levels = array(1,2,3); //update this to include ids of all levels you want to disable emails for
if(!empty($level) && !empty($level->id) && in_array( intval( $level->id ), $disabled_levels) && $email->template == "membership_recurring")
$recipient = NULL;
@femiyb
femiyb / register_helper_dropdown.php
Last active July 5, 2019 20:06
Register Helper Dropdown
<?php
//add lines 5 onwards to your custom PMPro plugin -> http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
<?php
/**
* Add the code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprorh_init() {
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
}
<?php
function limit_text_area()
{
echo
"
<script>
jQuery(document).ready(function() {
jQuery('#company_info').on('keyup', function() {
var words = this.value.match(/\S+/g).length;
<?php
function my_pmprorh_init_2()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
global $pmpro_countries;