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 / pmpro-cancel-level.php
Created April 16, 2021 15:05 — forked from greathmaster/pmpro-cancel-level.php
Give members a different level when expiring or cancelling based on their previous level.
/*
When users cancel (are changed to membership level 0) who previously belonged to
level 2 are given level 1 with expiration date of one year.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
$levelshistory = $wpdb->get_results("SELECT * FROM $wpdb->pmpro_memberships_users WHERE user_id = '$current_user->ID' ORDER BY id DESC");
if($levelshistory && $levelshistory[0]->membership_id == 2 && $level_id == 0)
{
@femiyb
femiyb / my_pmpropbc_enqueue_scripts.php
Last active March 30, 2021 10:33 — forked from messica/my_pmpropbc_enqueue_scripts.php
Hide Auto-Renewal Checkbox for Check payment
<?php
/**
* Hide Auto-Renewal Checkbox for Check payment
*/
function my_pmpropbc_enqueue_scripts() {
global $pmpro_pages;
if(is_page($pmpro_pages['checkout'])) {
@femiyb
femiyb / remove-sub-delay-add-on.php
Last active March 30, 2021 10:12 — forked from andrewlimaza/remove-sub-delay-add-on.php
Remove subscription delay for any previous member for PMPro.
<?php
/**
* Once a user checks out for a level, it will add usermeta to the user's account.
* This will then remove any subscription delay for that member in the future, even if the user cancels and then re-signs up.
*/
// Update level meta everytime a user changes their level to ensure they are blocked from subscription delays.
function my_pmpro_trial_used( $level_id, $user_id ) {
update_user_meta( $user_id, "pmpro_trial_level_used", "1" ); // Assume the user has any level.
}
@femiyb
femiyb / pmpro-logout-and-redirect-after-checkout.php
Created March 26, 2021 16:19 — forked from greathmaster/pmpro-logout-and-redirect-after-checkout.php
Log out the user after checkout and redirect them to a custom URL
<?php
// Log user out after check out
function my_pmpro_after_checkout($user_id)
{
wp_logout();
}
add_action('pmpro_after_checkout', 'my_pmpro_after_checkout');
@femiyb
femiyb / pmprosd_prorate_delay.php
Last active March 16, 2021 12:26 — forked from kimwhite/pmprosd_prorate_delay.php
Custom proration for a level with a subscription delay until a specified date (like "Y1-08-01"). Requires Paid Memberships Pro and Subscription Delays Add On.
<?php
/**
* This recipe will add custom proration for levels with a subcription delay
* until a specified date (like "Y1-08-01").
* Prorates initial payment based on days until end of subscription delay for level 1
*
* 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.
@femiyb
femiyb / 1-translate-pay-by-check-pmpro.php
Last active March 15, 2021 08:09 — forked from andrewlimaza/1-translate-pay-by-check-pmpro.php
Translating "Pay by Check" example for Paid Memberships Pro.
<?php
/**
* This will translate "Pay by Check" into "Pay by Cheque or Bank Transfer"
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* For more help visit www.paidmembershipspro.com
*/
function my_pmpro_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Pay by Check' :
@femiyb
femiyb / pmpro-adjust-the-join-now-login.php
Last active April 8, 2022 15:45 — forked from andrewlimaza/pmpro-adjust-the-join-now-login.php
Adjust the Paid Memberships Pro login "Join Now" Link.
<?php
/**
* Adjust the 'Join Now' link on the login page to a custom URL for Paid Memberships Pro.
* Follow this guide to add custom code to your membership site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_custom_join_now_link( $links, $allowed_html ) {
$links['register'] = '<a href="https://www.thefixxsquad.stylefixxdaily.com/pricing/">' . __( 'Join Now', 'paid-memberships-pro' ) . '</a>';
return $links;
}
add_filter( 'pmpro_login_forms_handler_nav', 'my_pmpro_custom_join_now_link', 10, 2 );
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
// Define the fields.
$fields = array();
$fields[] = new PMProRH_Field(
'machineId', // input name, will also be used as meta key
@femiyb
femiyb / my_pmpro_change_text_example.php
Last active March 25, 2022 13:57 — forked from MaryOJob/my_pmpro_change_text_example.php
PMPro - Change "Discount Code" Text Example on Checkout Page
<?php // Do Not Copy This Line
/**
* This recipe will help you change text on the checkout paid in PMPro
* 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/
*/
// paste content from below this line
function pmproc_change_my_text( $translated_text, $text, $domain ) {
@femiyb
femiyb / pmpro-dont-require-billing-fields.php
Last active March 1, 2021 15:02 — forked from ipokkel/pmpro-dont-require-billing-fields.php
Remove the Phone field from the required billing fields for PMPro checkout.
<?php
/**
* This recipe can be used to remove the Phone and Address 2 fields
* from the required billing fields for checkout.
*
* Note: Make sure your Gateway doesn't require it also.
*
* 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.