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_rh_checked_html_field.php
Created October 25, 2019 10:46
PMPro register helper pre-checked custom field example
<?php
//This code will be a full working example that will add 1 checkbox field to your checkout page for all levels. Please copy the code that you need.
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
@femiyb
femiyb / shipping_fields_optional.php
Last active May 5, 2021 15:00 — forked from andrewlimaza/shipping_fields_optional.php
make shipping fields optional PMPro
<?php
// Add this function to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function pmpro_hide_shipping_fields( $shipping_fields ) {
unset( $shipping_fields['bphone'] );
return $shipping_fields;
}
add_filter( 'pmproship_required_shipping_fields', 'pmpro_hide_shipping_fields' );
@femiyb
femiyb / custom.php
Created November 20, 2019 12:18
overwrite the text on Strong Passwords plugin
<?php
add_action( 'init', 'switch_my_pmpro_password_notice' );
function switch_my_pmpro_password_notice() {
if ( has_filter( 'pmpro_checkout_after_password', 'pmprosp_pmpro_checkout_after_password' ) ) {
remove_filter( 'pmpro_checkout_after_password', 'pmprosp_pmpro_checkout_after_password', 1 );
add_filter( 'pmpro_checkout_after_password', 'my_pmprosp_pmpro_checkout_after_password', 1 );
}
}
function my_pmprosp_pmpro_checkout_after_password() {
@femiyb
femiyb / toggle-checkbox.php
Last active April 17, 2020 15:31
Toggle checkbox
<?php
add_action( 'wp_head', function () {
if($post->ID == $pmpro_pages['checkout'])
{
?>
<script>
/* JavaScript code here */
window.onload = function() {
@femiyb
femiyb / my-show-user-start.php
Created November 29, 2019 18:35
* Show the user's start date.
<?php
/**
* Show the user's start date.
* Show the user's previously membership start date if they were cancelled, expired or cancelled by an admin.
* If none of thhe above is found, the string 'nothing found' will be returned.
*/
function my_show_user_startdate(){
if ( is_user_logged_in() && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel() ){
<?php
function translate_pmpro_text( $translated_text, $text, $domain )
{
if($domain == 'paid-memberships-pro') {
if($text == 'Membership invoice'){
$translated_text = 'Subscriber Invoice';
}
/*
Clear out all PMPro member and report data. (Back up your database first. Use at your own risk!!!)
This will delete all orders, members/level data, and reporting data.
Your levels, discount codes, and settings will remain in place.
All users will remain users (without memberships).
All subscriptions at the gateway will remain active.
To Use:
* Copy this code into your active theme's functions.php or a custom WP plugin.
* Navigate to /wp-admin/?pmprocleardata=1 when logged in as an admin.
@femiyb
femiyb / pmpro_check_username_length.php
Last active January 13, 2020 08:46
Set minimum length for username checkouts for Paid Memberships Pro
<?php
function pmpro_check_username_length( $pmpro_continue_registration ) {
//only bother if things are okay so far
if(!$pmpro_continue_registration)
return $pmpro_continue_registration;
$username = $_REQUEST['username'];
<?php
function my_pmpro_translate_to_german($translated_text, $original_text, $domain) {
switch ( $translated_text ) {
case 'Check Out with a Credit Card Here' :
$translated_text = __( 'Translation in German Here', 'paid-memberships-pro' );
break;
}
return $translated_text;
@femiyb
femiyb / add-category-restrictions-to-pages.php
Created January 3, 2020 10:06
Adds category restrictions to pages.
<?php
function add_taxonomies_to_pages()
{
register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'add_taxonomies_to_pages' );