Skip to content

Instantly share code, notes, and snippets.

Avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ipokkel
ipokkel / my-pmpro-confirmation-url.php
Created Oct 8, 2020
Redirect certain levels to a custom confirmation page after checkout.
View my-pmpro-confirmation-url.php
<?php
/**
* This recipe will allow you to send predefined Membership Levels to a unique confirmation page.
*
* 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_pmpro_confirmation_url( $url, $user_id, $level ) {
@ipokkel
ipokkel / example-custom-directory-widget.php
Last active Nov 20, 2020
Example custom directory widget with Membership Levels as a dropdown select.
View example-custom-directory-widget.php
<?php
/**
* Plugin Name: My PMPro Directory Widget
* Description: Add widget to Member Directory page to filter results.
*/
class My_PMPro_Directory_Widget extends WP_Widget {
/**
* Sets up the widget
@ipokkel
ipokkel / my-pmprorh-read-only.php
Created Jul 29, 2020
Set Register Helper field to read only for members but not administrators or membership managers with the readonly field option.
View my-pmprorh-read-only.php
<?php
/**
* This recipe creates a custom fields for membership registration
* that is readonly on the user edit profile for members and
* editable by administrators or users with the membership manager role.
*
* This recipe assumes that the registration field is required during checkout.
*
* @requires Register Helper Add On
* @link https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
@ipokkel
ipokkel / my-pmpro-member-links-top-gifting.php
Last active Nov 19, 2020
Add a "Buy Gif Level" on the account page for Member Links #gift #pmpro-gift-levels
View my-pmpro-member-links-top-gifting.php
@ipokkel
ipokkel / my-pmpro-account-profile-action-links-gifting.php
Last active Nov 19, 2020
Add a "Buy Gif Level" on the account page for profile action links #gift #pmpro-gift-levels
View my-pmpro-account-profile-action-links-gifting.php
@ipokkel
ipokkel / my-pmpro-member-action-link-gifting.php
Last active Nov 19, 2020
Add a "Buy Gif Level" on the account page for member action links #gift #pmpro-gift-levels
View my-pmpro-member-action-link-gifting.php
View directory-widget-select2.php
<?php
function my_pmprorh_init_example_fields() {
// 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(
@ipokkel
ipokkel / my-pmpro-directory-widget-sql-parts.php
Created May 13, 2020
Custom SQL query for PMPro Directory Widget that also filters field values stored as arrays
View my-pmpro-directory-widget-sql-parts.php
<?php
function my_pmpro_directory_widget_filter_sql_parts( $sql_parts, $levels, $s, $pn, $limit, $start, $end, $order_by, $order ) {
global $wpdb;
// Filter results based on ares of practice is selected.
if ( ! empty( $_REQUEST['areasofpractice'] ) && is_array( $_REQUEST['areasofpractice'] ) ) {
$sql_parts['JOIN'] .= " LEFT JOIN $wpdb->usermeta um_areasofpractice ON um_areasofpractice.meta_key = 'areasofpractice' AND u.ID = um_areasofpractice.user_id ";
$sql_parts['WHERE'] .= ' AND ( ';
$first_areasofpractice = true;
@ipokkel
ipokkel / my-template-redirect-pmpro-multisite-membership-require-membership-access.php
Created Jan 17, 2020
Redirects members-only content to the Membership Levels page if a user is logged out or not a member in a multisite network using the PMPro Multisite Membership Add On.
View my-template-redirect-pmpro-multisite-membership-require-membership-access.php
<?php
/**
* my_template_redirect_pmpro_multisite_membership_require_membership_access
*
* Redirects members-only content to the Membership Levels page
* if a user is logged out or not a member in a multisite network.
* @requires Multisite Membership Add On [pmpro-network-subsites]
*/
function my_template_redirect_pmpro_multisite_membership_require_membership_access() {
@ipokkel
ipokkel / my-pmproconpd-cancel-trial-immediately.php
Created Nov 17, 2020
Cancel On Next Payment Date Add On - Do not extend membership to next payment date when member in a trial period
View my-pmproconpd-cancel-trial-immediately.php
<?php
/**
* This recipe will cancel membership immediately when
* using the Cancel On Next Payment Date Add On and
* not extend the membership to the next payment date
* if the member is still in a trial period.
*
* This works for default trial levels as well as
* trial periods set with the Subscription Delay Add On.
*
You can’t perform that action at this time.