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
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
@femiyb
femiyb / change_expiration_level_text.php
Last active February 27, 2019 14:34
Change expiration level text and display number of days left
<?php
function change_text_for_pmpro_renewal( $text, $level ) {
// check if user is logged in else bail.
if( !is_user_logged_in() ) {
return $text;
}
global $current_user;
$membership = $current_user->membership_level;
<?php
/*
Hide billing address fields and make them optional.
*/
//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;
<?php
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
}
$fields = array();
$fields[] = new PMProRH_Field(
<?php
//record when users gain the trial level
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
global $trial_level_ids;
if(in_array($level_id, $trial_level_ids))
{
//add user meta to record the fact that this user has had this level before
update_user_meta($user_id, "pmpro_trial_level_used", "1");
<?php
// REGISTER HELPER
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
}
$fields = array();
<?php
/*
Disable the "Admin Checkout" emails in Paid Memberships Pro
*/
function my_pmpro_email_recipient($recipient, $email)
{
$user = get_user_by( $email, $recipient );
$user_level = pmpro_getMembershipLevelForUser( $user );
if(($email->template == "checkout_paid_admin" || $email->template == "checkout_free_admin") && ($user_level->ID == '4')) //could check for a different template here
$recipient = NULL;
@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;
<?php
/**
* This recipe will forward the Membership Expiring email to another email address
*
* 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_email_recipient($headers, $email) {
<?php
/*
Disable the "Membership Recurring" emails in Paid Memberships Pro
*/
function my_pmpro_email_recipient($recipient, $email)
{
$user = get_user_by( $email, $recipient );
$user_level = pmpro_getMembershipLevelForUser( $user );