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
function my_pmprorh_init_2()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
<?php
/**
* Add this code to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This function below sends a custom HTML email to the user that checks out for a pmpro membership level, easily extendible to send to admins, or specific users and so on.
* Website: https://paidmembershipspro.com
*/
//this gist will send a custom email when a new member is added using the add member add on
@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 );
<?php
/*
Change text
*/
function my_pmpro_gettext_membership($translated_text, $text, $domain)
{
$translated_text = str_replace("LEVEL", "LEVEL Changed text", $translated_text);
@femiyb
femiyb / disable_registration_based_on_rh_fields_value.php
Last active September 30, 2019 10:53
Disable Registration based on Register Helper field value
<?php
/*
Disable Registration based on Register Helper field value
Add this code to your active theme's functions.php or
a custom plugin.
*/
function my_pmpro_registration_checks($okay)
{
//only check if things are okay so far
if($okay)
@femiyb
femiyb / pmpro_redirect_after_checkout.php
Created October 8, 2019 06:34
Redirect After Checkout
<?php
function my_pmpro_confirmation_url($rurl, $user_id, $pmpro_level)
{
$rurl = 'http://google.com'; //change this URL
return $rurl;
}
add_filter('pmpro_confirmation_url', 'my_pmpro_confirmation_url', 10, 3);
@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";
<?php
/**
* Redirect users to aacount page after login
*/
function pmpro_redirect_after_login( $redirect_to, $request, $user ) {
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check if user is not an admin.
if ( !in_array( 'administrator', $user->roles ) ) {
@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);