Skip to content

Instantly share code, notes, and snippets.

View lubyagin's full-sized avatar

Александр lubyagin

View GitHub Profile
@andrewlimaza
andrewlimaza / change_body_for_email.php
Created January 9, 2018 06:56
Change body content according to level checkout for Paid Memberships Pro.
<?php
/**
* Change body text of email according to level checkout.
* Assumes level ID is 1.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_body( $body, $email ) {
@andrewlimaza
andrewlimaza / rename_invoice.php
Created December 18, 2017 14:37
Change Invoice to Tax Invoice Paid Memberships Pro
<?php
/**
* Change all 'invoice' to 'tax invoice'
* Add this code to PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function theme_change_comment_field_names( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
@andrewlimaza
andrewlimaza / remove_redirect_memberhomepages.php
Created December 15, 2017 14:37
Remove homepage replacement for Member Home Pages Paid Memberships Pro
<?php
/**
* Removes the always redirect to member homepages. Only allows login redirect functionality.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function remove_memberhome_pages_redirect(){
remove_action('template_redirect', 'pmpromh_template_redirect_homepage');
}
@andrewlimaza
andrewlimaza / pmpro_free_shipping_to_members.php
Last active February 19, 2019 23:26
Offer Free shipping to PMPro Members.
<?php
/**
* If user does not have a membership level only offer flat rate.
* If is a Paid Memberships Pro, force free shipping!
*
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*
* PLEASE NOTE: Clear WooCommerce Transients for this to take affect if not working.
@andrewlimaza
andrewlimaza / pmpro_stripe_checkout.php
Created October 31, 2017 07:19
Add stripe as a checkout option with PMPro.
function my_pmpro_valid_gateways( $gateways ) {
$gateways[] = "stripe";
return $gateways;
}
add_filter( "pmpro_valid_gateways", "my_pmpro_valid_gateways" );
function my_pmpro_checkout_boxes() {
?>
<a href="?level=<?php echo intval($_REQUEST['level']);?>&gateway=stripe">Checkout with Stripe</a>
<?php
@andrewlimaza
andrewlimaza / redirect_users_after_login.php
Last active July 20, 2021 09:28
Redirect Users After Login For WordPress
<?php
/**
* Redirect all non-admin user's after they login to your website's home page.
* Documentation for login_redirect filter - https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect
* Visit https://yoohooplugins.com for more tutorials.
*/
function yh_redirect_after_login( $redirect_to, $request, $user ) {
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
@andrewlimaza
andrewlimaza / pmpro_level_select_button.php
Last active February 19, 2019 23:25
Change class for PMPro Level Select button.
<?php
// Add this function to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function change_pmpro_level_button_class() {
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.pmpro_level-select a').attr('class', 'button'); //add 'button' class to level select buttons.
@andrewlimaza
andrewlimaza / remove_first_and_last_name_from_checkout.php
Created September 21, 2017 15:46
Remove first and last name for certain levels for
<?php
/**
* Remove fields from certain levels for the Add Name To Checkout - https://www.paidmembershipspro.com/add-ons/add-first-last-name-to-checkout/
* Add this to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function remove_name_from_fields() {
$levels_to_remove_fields_from = array( '1', '2', '3', '4', '5' ); //change the level ID's in this to hide the fields from this.
@andrewlimaza
andrewlimaza / make_old_posts_free.php
Created September 19, 2017 11:32
Make posts older than 30 days free in PMPro
<?php
// Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
/*
Make any post older than 18 months available for free.
Add this code to your active theme's functions.php or a
custom plugin.
*/
@andrewlimaza
andrewlimaza / allow_non_members_access.php
Created September 13, 2017 12:53
Allow non-members temporary access to restricted PMPro Content until a certain date.
<?php
/**
* Allow temporary access to all restricted content for non-members until a certain date.
* Add this function below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_allow_temp_access_for_non_members($hasaccess, $mypost, $myuser, $post_membership_levels){