Skip to content

Instantly share code, notes, and snippets.

View lubyagin's full-sized avatar

Александр lubyagin

View GitHub Profile
@andrewlimaza
andrewlimaza / pmpro-auto-password-generation.php
Created May 10, 2018 12:55 — forked from strangerstudios/pmpro-auto-password-generation.php
Auto generate passwords with Paid Memberships Pro
/*
Automatically generate password on checkout page.
Note: if you want to remove the entire user area and generate usernames and passwords, simply set the pmpro_skip_account_fields filter to return false.
Use the intstructions here (http://www.paidmembershipspro.com/documentation/advanced-techniques/templates/) to add a checkout page template with the password fields removed.
Uncheck the "Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)" option in the PMPro Emails Settings tab.
*/
function my_generate_passwords()
@andrewlimaza
andrewlimaza / load-my-ssl-seal-to-checkout.php
Created May 8, 2018 08:12
load SSL seal to checkout page PMPro before submit button
<?php
/**
* Add the function (below) to your PMPro Customizations Plugin.
* This will add your SSL Seal code just before the submit button of checkout.
*/
function load_my_ssl_seal_to_checkout() {
echo '<!--- DO NOT EDIT - GlobalSign SSL Site Seal Code - DO NOT EDIT --><table width="125" border="0" cellspacing="0" cellpadding="0" title="CLICK TO VERIFY: This site uses a GlobalSign SSL Certificate to secure your personal information."><tr><td><span id="ss_img_wrapper_gmogs_image_125-50_en_white"><a href="https://www.globalsign.com/" target="_blank" title="GlobalSign Site Seal" rel="nofollow"><img alt="SSL" border="0" id="ss_img" src="//seal.globalsign.com/SiteSeal/images/gs_noscript_125-50_en.gif"></a></span></td></tr></table><!--- DO NOT EDIT - GlobalSign SSL Site Seal Code - DO NOT EDIT -->';
}
add_action( 'pmpro_checkout_before_submit_button', 'load_my_ssl_seal_to_checkout' );
@andrewlimaza
andrewlimaza / pmpro-adjust-price-for-members.php
Created May 2, 2018 11:29
Adjust checkout pricing for existing members for Paid Memberships Pro.
<?php
/**
* This will adjust membership pricing depending on users current level and level checking out for. See line 10.
* This will show you how to adjust the initial amount and/or the recurring amount. If the existing level, in this case 5, is not a recurring level please uncomment lines 12-14.
* Add this code (L8 - L20) to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_adjust_price_for_members( $level ) {
// Adjust price for existing members that currently have level 2.
@andrewlimaza
andrewlimaza / remove-homepage-replacement.php
Last active February 19, 2019 17:09
Remove homepage replacement for admins only (Paid Memberships Pro HomePages Add On)
<?php
/**
* Remove the homepage replacement on the Member HomePages Add On for Paid Memberships Pro.
* This will only remove the homepage replacement for administrators.
* Add this code (L9-L14 only) to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function remove_memberhome_pages_redirect(){
if ( current_user_can( 'manage_options' ) ) {
@andrewlimaza
andrewlimaza / pmpro-hide-content-from-members.php
Last active September 12, 2023 12:43
Hide posts with certain category from members.
<?php
/**
* This code allows you to filter the default blog (archive) page to hide posts with certain category ID's from members.
* This is useful if you want to hide free content from paying members.
* Adjust line 16 & 21 to your needs. If the user does not have a membership level, the posts page won't be filtered/changed.
*
* Add the code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Reference: https://developer.wordpress.org/reference/hooks/pre_get_posts/
* www.paidmembershipspro.com
*/
@andrewlimaza
andrewlimaza / pmpro_billing_page_link.php
Created April 4, 2018 13:10
Billing Page link added to PMPro Account Page.
@andrewlimaza
andrewlimaza / add-text-before-submit-button-example.php
Created March 27, 2018 11:10
Add text before submit button in Paid Memberships Pro
<?php
/**
* Adds text before the submit button on the checkout page.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function add_text_before_submit() {
echo 'Credit Card & PayPal Payments';
}
add_action( 'pmpro_checkout_before_submit_button', 'add_text_before_submit' );
@andrewlimaza
andrewlimaza / pmpro-sql-cancelled-in-7days
Created March 22, 2018 14:36
Example to see all user's that cancelled within 7 days SQL
global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM $wpdb->pmpro_memberships_users WHERE status='cancelled' AND enddate IS NOT NULL AND DATE_ADD(startdate, INTERVAL 7 DAY) >= enddate AND membership_id='1'" );
@andrewlimaza
andrewlimaza / first-time-login-redirect.php
Created March 19, 2018 08:55
First Time Login Redirect For Paid Memberships Pro
<?php
/**
* Redirect a member for first time login.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* www.paidmembershipspro.com
*/
function first_time_login_redirect( $redirect_to, $request, $user ) {
//check level
if ( ! empty( $user ) && ! empty( $user->ID ) && function_exists( 'pmpro_getMembershipLevelForUser' ) ) {
@andrewlimaza
andrewlimaza / redirect-non-approved-member-from-account-page-pmpro.php
Last active February 19, 2019 23:25
Redirect non approved members from their account Page ( Paid Memberships Pro )
<?php
/**
* Redirect non-approved members from the Membership Account Page for Paid Memberships Pro.
* Requires PMPro Approvals Add On to be installed - https://www.paidmembershipspro.com/add-ons/approval-process-membership/
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* www.paidmembershipspro.com
*/
function my_redirect_non_approved_members(){
global $current_user;