Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ipokkel
ipokkel / redirect-login-last-post-custom.php
Last active January 30, 2020 11:19 — forked from ideadude/my_redirect_to_last_post_id.php
On WordPress login, redirect to the last post you were viewing or custom page if no last page available
<?php
/**
* On login, redirect to the last post viewed or custom page if no last page available.
* Add this code into a custom plugin.
* Note that many themes and plugins hook into login_redirect.
* Whichever hook has the highest priority will be the last call
* on where to redirect. The priority below is set to 20.
* Note also that some URLs/pages may note be "posts"
* and may not have an ID we can track.
@ipokkel
ipokkel / pmprorh-make-profile-fields-required.php
Last active February 2, 2020 11:07 — forked from greathmaster/pmprorh-make-profile-fields-required.php
Require register helper fields set as required in the edit user form when a user edits or updates their profile. $pmpro #rh #profile
<?php
/**
* This recipe makes required Register Helper fields added to the profile
* required in the user edit profile form.
*
* Requires the Register Helper field atributes profile and required set to true, e.g.
* 'profile' => true,
* 'required' => true,
*
@ipokkel
ipokkel / redirect_users_to_a_new_page.php
Last active January 28, 2020 05:09 — forked from andrewlimaza/redirect_users_to_a_new_page.php
Redirect users away from 'account' page in PMPro if they do not have a membership/logged-in #pmpro #account #redirect #slug
<?php
/**
* Redirect user's to a new URL instead of the 'levels' page in PMPro.
* Add this code to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function redirect_users_to_a_new_page( $url ){
return home_url('my-landing-page-slug'); //change this to the page slug you would like to redirect your user's to.
@ipokkel
ipokkel / my_template_redirect_require_membership_access.php
Last active January 17, 2020 02:36 — forked from kimcoleman/my_template_redirect_require_membership_access.php
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.
<?php
/*
* Redirects members-only content to the Membership Levels page if a user is logged out or not a member.
*/
function my_template_redirect_require_membership_access() {
if ( function_exists( 'pmpro_has_membership_access' ) && ! pmpro_has_membership_access() ) {
if ( ! is_multisite() && ! function_exists( 'pmpro_multisite_membership_init' ) ) {
wp_safe_redirect( pmpro_url( 'levels' ) );
exit;
@ipokkel
ipokkel / display-custom-register-helper-fields-in-signup-shortcode.php
Last active January 8, 2020 10:15 — forked from MaryOJob/my_pmpro_custom_select_and_text_fields_to_register_helper.php
Create custom Register Helper fields and hook them into a different location to display in Signup Shortcode #pmpro #signup #shortcode
<?php
/*
This code example serves as an experimental example.
The preferred method of showing custom fields in the signup shortcode is to use the shortcode attribute custom_fields
[pmpro_signup submit_button="Unlock this Post Now!" level="1" login="1" redirect="referrer" custom_fields="true"]
See - https://www.paidmembershipspro.com/add-ons/pmpro-signup-shortcode/
*/
@ipokkel
ipokkel / pmpro_format_my_phone.php
Last active December 16, 2024 09:51 — forked from travislima/pmpro_format_my_phone.php
Format the Phone number of Paid Memberships Pro - Customized Example
<?php
/**
* This code gist illustrates a way to customize the format of your members phone number.
*
* In this example, we will change the PMPro phone number from
*
* (123)456-7890
* to 1234567890
*
* Adjust this code gist to suit your needs for phone number.
@ipokkel
ipokkel / my_pmpro_applydiscountcode_return_js.php
Last active November 21, 2019 08:22 — forked from messica/my_pmpro_applydiscountcode_return_js.php
Display original price and discount when a discount code is applied. Modified to display original price on discount code error
<?php
/**
* Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order.
* Add this code recipe to a PMPro Customization Plugin - Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order
* Various classes added to strings to allow for styling - ".pmpro-discorig-message", ".pmpro-orginal-price", ".pmpro-discount-price", ".pmpro-save-price"
*
* [my_pmpro_applydiscountcode_return_js] Display original price and discount when a discount code is applied.
* @param string $discount_code [description]
* @param integer $discount_code_id [description]
@ipokkel
ipokkel / pmproseries_shortcode.php
Last active August 4, 2020 06:51 — forked from messica/pmproseries_shortcode.php
Adds a [my_pmpro_series] shortcode to display a specific series post list.
<?php
/**
* This recipe creates a [my_pmpro_series] shortcode
* to display a specific series post list.
*
* This shortcode requires that a Series (Post) ID is provided.
*
* To obtain the Post ID for a series, from the
* WordPress dashboard navigate to Series > Series,
* click on the series name, in the edit page URL
@ipokkel
ipokkel / pmpro_gettext_membership_options.php
Last active November 7, 2019 10:40 — forked from LMNTL/pmpro_gettext_membership_options.php
Hide "View all Membership Options" link on PMPro Account page
<?php //Do NOT copy this line
/* Hide "View all Membership Options" link */
add_filter( 'gettext', 'my_gettext_pmpro_hide_view_membership_options', 10, 3 );
function my_gettext_pmpro_hide_view_membership_options( $translated_text, $text, $domain ) {
if ( $pmpro_pages['account'] && 'paid-memberships-pro' == $domain && 'View all Membership Options' == $text ) {
$translated_text = '';
}
return $translated_text;
}
@ipokkel
ipokkel / my-pmpro-invoice-address.php
Last active October 18, 2019 08:43 — forked from strangerstudios/my_pmpro_invoice_address.php
Add and translate your business address and VAT number to the Membership Invoice and Membership Confirmation pages.
<?php // Do NOT copy this line
// Add this code below to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
add_action( 'pmpro_invoice_bullets_bottom', 'my_pmpro_invoice_address' );
function my_pmpro_invoice_address() {
?>
<li><strong><?php _e( 'Paid To', 'pmpro-customizations' ); ?>:</strong><br />My Business<br />123 The Street<br />City, XX 12345 USA</li>
<li><strong><?php _e( 'VAT Number', 'pmpro-customizations' ); ?>:</strong> BG999999999</li>
<?php