Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Femi YB femiyb

🏠
Working from home
View GitHub Profile
View functions.php
<?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 Feb 27, 2019
Change expiration level text and display number of days left
View change_expiration_level_text.php
<?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;
View display_only_postal_code_on_billing_field.php
<?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;
View my_pmprorh_init.php
<?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(
View pmpro_trial_level_once_per_discount_code.php
<?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");
View register_helper.php
<?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();
View disable_admin_checkout_emails.php
<?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 Mar 25, 2019 — 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.
View wp_head_hide_billing_fields.php
/*
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;
View send_email_to_admins.php
<?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) {
View membership_recurring.php
<?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 );