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.php
Last active August 16, 2021 16:11
Upload file with delete option and allow extension option
<?php
/**
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it.
* For more information on the Register Helper Add-on please visit https://www.paidmembershipspro.com/add-ons/free-add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
**/
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
<?php
add_filter( 'gettext', 'change_my_cost_example', 20, 3 );
/**
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function change_my_cost_example( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
@femiyb
femiyb / show-pmpro-address-fields-on-profile.php
Created April 14, 2020 09:27 — forked from pbrocks/show-pmpro-address-fields-on-profile.php
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page
<?php
/**
* Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page.
*/
/**
* show_pmpro_address_fields_on_edit_profile Grabs the values from the billing fields which get filled in during checkout and displays on User Profile.
*
* @return array Array of Register Helper field objects
*/
function show_pmpro_address_fields_on_edit_profile() {
@femiyb
femiyb / my_pmpro_confirmation_message.php
Last active August 14, 2021 02:12
Adjust Confirmation Message
<?php
/**
* This changes the default confirmation message when a user checks out.
*
* 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/
*/
@femiyb
femiyb / pmpro-remove-user-membership-order-data.php
Last active April 16, 2020 17:36 — forked from JarrydLong/pmpro-remove-user-membership-order-data.php
Removes a user's membership order data either by manually adding in a query param, or when deleting a user through /wp-admin/
<?php
/**
* Remove user order manually by adjusting the ID's in the array, or adding them into a
* query param by setting it to /?reset_test_accounts=true&accounts=2,3
*/
function pmpro_remove_orders( $user_id = null ){
if( isset( $_REQUEST['reset_test_accounts'] ) && $_REQUEST['reset_test_accounts'] == 'true' ){
global $wpdb;
@femiyb
femiyb / my_pmpro_term_template_redirect.php
Last active April 21, 2020 07:22 — forked from strangerstudios/my_pmpro_term_template_redirect.php
Redirect non-members away from CPTs with specific term
<?php
function my_pmpro_term_template_redirect() {
global $post;
//change category and level ID here
if( has_term('PGreen-blog', 'content_type', $post) && 351 == $post->ID && !pmpro_hasMembershipLevel())
{
wp_redirect(pmpro_url('levels'));
exit;
}
}
<?php
/**
* This sends PMPro admin emails to another email.
*
* 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_pmproec_pmpro_email_body($body, $email)
{
//must be a confirmation email and checkout template
if(!empty($email->data['membership_id']) && pmproec_isEmailConfirmationLevel($email->data['membership_id']) && strpos($email->template, "checkout") !== false)
{
//get user
$user = get_user_by("login", $email->data['user_login']);
$validated = $user->pmpro_email_confirmation_key;
$url = home_url("?ui=" . $user->ID . "&validate=" . $validated);
//need validation?
@femiyb
femiyb / my_gettext_pay_by_check.php
Last active April 24, 2020 13:01 — forked from strangerstudios/my_gettext_pay_by_check.php
Update Pay by Check wording in pmpro-pay-by-check to something else.
<?php
/*
Change "Pay by Check" language to "Pay by Bank"
Add this code to your active theme's functions.php
or a custom plugin.
*/
function my_gettext_pay_by_check($translated_text, $text, $domain)
{
if($domain == "pmpro-pay-by-check" && $text == "Pay by Check")
@femiyb
femiyb / unset-and-hide-billing-state-field.php
Last active January 4, 2021 12:50 — forked from ipokkel/unset-and-hide-billing-state-field.php
PMPro - Remove state from required billing fields and hide it the state field.
<?php // Do NOT copy this line
/* Copy from below this line */
/*
Remove state from required billing fields and hide it the state field.
*/
// Unset state
add_action( 'pmpro_required_billing_fields', 'my_pmpro_required_billing_fields' );