Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
/**
* This query will retrieve all active memberships for users including MMPU orders
* You'll need to change the wp_ database prefix on lines 21 - 24 to match your database prefix.
*/
SELECT
DISTINCT u.ID,
u.user_login,
u.user_email,
u.user_login,
u.user_nicename,
@andrewlimaza
andrewlimaza / qr-code-invite-members.php
Created October 9, 2020 10:59
Integrate Membership Card with Invite Only Member Add On [Paid Memberships Pro]
<?php
/**
* Set the QR code to link to a checkout with an invite code when someone scans a Q.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_membership_card_qr_invite_code( $card_user, $option ) {
global $pmproio_invite_required_levels;
if ( $option == 'other' ) {
@dparker1005
dparker1005 / pmproiufcsv_email.php
Created September 18, 2020 17:47
Send a welcome email for each user after CSV import.
<?php
// Copy from below here...
/**
* Send a welcome email for each user after CSV import.
*/
global $pmproiufcsv_email;
$pmproiufcsv_email = array(
'subject' => sprintf('Welcome to %s', get_bloginfo('sitename')), //email subject, "Welcome to Sitename"
@andrewlimaza
andrewlimaza / my-pmpro-change-display-name-member-directory.php
Created August 27, 2020 09:32
Change the display name for Member Directory and Profile Pages Add On
<?php
/**
* Replace a user's display name on directory and profile page with their full name.
* This requires the latest version (1.0+) of the Member Directory and Profile Pages Add On - https://www.paidmembershipspro.com/add-ons/member-directory/
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_member_directory_change_display_name( $display_name, $user ) {
$first_name = isset( $user->first_name ) ? $user->first_name : get_user_meta( $user->ID, 'first_name', true );
$last_name = isset( $user->last_name ) ? $user->last_name : get_user_meta( $user->ID, 'last_name', true );
@ronalfy
ronalfy / pmpro-template-user-pages-level-id.php
Last active August 28, 2020 13:30
PMPro - Template for User Pages Based on Level ID.
<?php
/**
* Load a page template for a user page based on level.
*/
function pmpro_user_page_redirect_per_level() {
// Make sure user is logged in.
if ( ! is_user_logged_in() ) {
return;
}
// Make sure we are on a page.
@dparker1005
dparker1005 / checkout_levels_api_demo.php
Last active February 29, 2024 18:06
2 demos to demonstrate the PMPro checkout_levels API call.
<?php
// Copy from below here...
/*
* Add widget to checkout to get result of checkout_levels API call when button is pressed.
*/
function my_pmpro_test_checkout_levels_api() {
?>
<hr/>
@kimcoleman
kimcoleman / my_pmpro_email_template_header_footer.php
Created August 9, 2020 16:51
Apply the Email Header and Email Footer as set in the Memberships > Email Templates admin page to the WP New User Notification.
@andrewlimaza
andrewlimaza / rh-file-upload-members-csv.php
Created July 31, 2020 08:24
Add Register Helper File Upload Field to Member's CSV Export
<?php
/**
* Add the full URL of a file upload field to member export CSV.
* Adjust the 'my_image' value with the relevant Register Helper field key.
* You can add this code snippet to your WordPress site following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Add a custom column to the CSV export.
function my_pmpro_members_list_csv_extra_columns ( $columns ) {
$columns["uploaded"] = "my_pmpro_members_list_uploaded";
@kimcoleman
kimcoleman / login_redirect_to_referrer.php
Created July 30, 2020 13:39
Always redirect user to referrer after log in if no other redirects are set.
<?php
/**
* Always redirect user to referrer after log in if no other redirects are set.
*
*/
function login_redirect_to_referrer( $redirect_to, $request, $user ) {
// If already redirecting, do that.
if ( ! empty( $redirect_to ) ) {
return $redirect_to;
@kimcoleman
kimcoleman / remove_the_pmpro_actions_nav_separator.php
Last active March 30, 2021 03:43
Remove the vertical bar | in the various action nav groups on Membership Account, Log In widget, and more.
<?php
/**
* Remove the vertical bar | in the various action nav groups on Membership Account, Log In widget, and more.
*
* 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/
*
*/