Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / discount_code_search_for_pmpro_members_list.php
Created January 16, 2019 15:59
Update PMPro member and order searches to also search by discount code.
/**
* Update member and order searches to also search by discount code.
*
* I'm not recommending anyone actually use this, but sharing as an example.
*
* This is a little hacky how the members list SQL is edited.
* You get odd results if you change the level or other parameters
* on the members list table and also search for an order.
* Can also act wonky if you have overlaps between your discount code names
* and cities, user names, names, or anything else that would normally
@ideadude
ideadude / my_add_select2_to_discount_code_filter_on_orders_page.php
Last active January 16, 2019 16:18
Turn Discount Code dropdown on the PMPro orders list to a select2 field.
/**
* Turn Discount Code dropdown on orders list to a select2 field.
* Add this code to a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_add_select2_to_discount_code_filter_on_orders_page() {
if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'pmpro-orders' ) {
wp_enqueue_style( 'select2', plugins_url( 'css/select2.css', __FILE__ ), '', '4.0.6', 'screen' );
wp_enqueue_script( 'select2', plugins_url( 'js/select2.js', __FILE__ ), array( 'jquery' ), '4.0.6' );
function my_add_select2_inline_script() {
@ideadude
ideadude / membership_shortcode_examples.txt
Created January 16, 2019 20:16
Examples of the PMPro [membership] shortcode.
[membership level="0"]
<!--this is shown to non-members and non-logged in visitors-->
[pmpro_advanced_levels levels="1,2,3" layout="3col"]
[/membership]
[membership level="1,2"]
[pmpro_advanced_levels levels="2,3" layout="2col"]
<!--this is shown to Level 1 and 2 Members-->
[/membership]
[membership level="3"]
[pmpro_advanced_levels levels="4"]
@ideadude
ideadude / membership_shortcode_login_message.txt
Created January 16, 2019 20:17
Use the PMPro membership shortcode to show a login link to logged out users.
[membership level="0"]
<!--this is shown to non-members and non-logged in visitors-->
<div class="pmpro_message pmpro_alert">
Already a member? Log In to unlock additional membership options.
</div>
[/membership]
@ideadude
ideadude / pmpro_xof_currency_format.php
Created February 12, 2019 13:21
Add a XOF currency to Paid Memberships Pro
/**
* Add a XOF currency to Paid Memberships Pro
* Add this code into a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_xof_currency_format( $pmpro_currencies ) {
$pmpro_currencies['XOF'] = array(
'name' => __( 'West African Franc', 'paid-memberships-pro' ),
'decimals' => '2',
'thousands_separator' => ',',
'decimal_separator' => '.',
@ideadude
ideadude / pmpro-cpt.php
Last active June 19, 2023 22:43 — forked from strangerstudios/pmpro-cpt.php
Add the PMPro meta box to a CPT. Add this to your plugin/etc.
<?php
/**
* Add the PMPro meta box to a CPT
*/
function my_add_pmpro_meta_box_to_cpts() {
// Duplicate this row for each CPT. This one adds the meta boxes to 'product' CPTs.
add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'product', 'side' );
}
add_action( 'admin_menu', 'my_add_pmpro_meta_box_to_cpts', 20 );
@ideadude
ideadude / my_require_cvv_for_reals.php
Last active February 15, 2019 13:26
Set CVV as a Required Field with PMPro
/**
* Set CVV as a Required Field with PMPro
* Add this code to a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* NOTE: Doesn't yet work with all gateways.
* You'll need to make sure the gateway is set to require CVV/CVC
* and then add an elseif ( ... ) below to set the $CVV var
* if you see a valid gateway token/etc.
*/
function my_require_cvv_for_reals( $fields ) {
@ideadude
ideadude / custom_account_page_for_pmpro_and_memberlite.txt
Created February 21, 2019 18:24
Custom account page for PMPro and Memberlite. Copy this into the post body instead of the default [pmpro_account] shortcode.
[row]
[col medium="6"]
[pmpro_account section="profile"]
[/col]
[col medium="6"]
[pmpro_account section="membership"]
[/col]
[/row]
[row]
@ideadude
ideadude / my_pmpro_after_change_membership_level.php
Last active March 21, 2019 12:51 — forked from strangerstudios/my_pmpro_after_change_membership_level.php
Only allow users to use the trial level once with Paid Memberships Pro.
<?php
/*
Only allow users to use the trial level once.
Add this code to your active theme's functions.php
or a custom plugin.
Be sure to change the $trial_level_id variable in multiple places.
*/
//get trial level ids
function my_pmpro_trial_level_ids() {
// edit this to be a comma separated list of your trial level ids
@ideadude
ideadude / disable_pmpro_send_html.php
Last active May 25, 2020 08:53
Disable the PHPMailer Code for PMPro
/**
* Disable the custom PHPMailer Code for PMPro.
* This will sometimes fix issues with broken/scrambled emails.
* Add this code to a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Notice we run on the wp_mail_content_type hook on priority 15 to make sure
* we run after PMPro sets up the hook here: https://github.com/strangerstudios/paid-memberships-pro/blob/dev/includes/email.php#L127-L137
*/
function my_disable_pmpro_send_html() {
remove_action('phpmailer_init', 'pmpro_send_html');
}