Skip to content

Instantly share code, notes, and snippets.

View lubyagin's full-sized avatar

Александр lubyagin

View GitHub Profile
@andrewlimaza
andrewlimaza / show-renewal-link-on-30-days-or-less.php
Last active January 23, 2023 13:47
Change when to show the renewal link on Paid Memberships Pro account page.
@andrewlimaza
andrewlimaza / my_pmprowoo_get_membership_price.php
Created July 4, 2018 16:52 — forked from ideadude/my_pmprowoo_get_membership_price.php
Use the pmprowoo_get_membership_price filter to set prices for variable products with Paid Memberships Pro and WooCommerce
<?php
/**
* Use the pmprowoo_get_membership_price filter to set prices for variable products.
* Update the $membership_prices array.
* Each item in that array should have a key equal to the membership level id,
* and a value equal to an array of the form array( {variable_product_id} => {member_price} )
*
* Add this code into a custom plugin.
*/
function my_pmprowoo_get_membership_price( $discount_price, $level_id, $original_price, $product ) {
@andrewlimaza
andrewlimaza / give-access-to-anyone-with-a-code-passphrase-pmpro.php
Created July 2, 2018 10:54
Give temporary access to anyone with a special phrase / code to Paid Memberships Pro restricted content
<?php
/**
* This will allow any post or feed to be open if a user has a special passphrase or key.
* Please change 'abc' to a special passphrase/secret key and change this regularly.
* This will open any restricted post if a parameter of `&my-key=abc` is passed in the URL, for example my-site.com/feed/?my-key=abc
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_rss_access_filter($hasaccess, $mypost, $myuser, $post_membership_levels) {
@andrewlimaza
andrewlimaza / pmpro-account-bullets-top-example.php
Created July 2, 2018 08:52
pmpro_account_bullets_top example
<?php
// Copy code below to PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function pmpro_account_bullets_top_example() {
echo '<li><strong>Useful Link: </strong><a href="some-link">Click this link to go somewhere</a> </li>';
}
add_action( 'pmpro_account_bullets_top', 'pmpro_account_bullets_top_example' );
@andrewlimaza
andrewlimaza / customize-wordpress.php
Created June 25, 2018 15:44
The Right Way To Customize WordPress
<?php
/**
* Plugin Name: My Plugin
* Plugin URI: https://www.yoohooplugins.com
* Description: Customizations for WordPress
* Version: 1.0
* Author: Yoohoo Plugins
* Author URI: https://www.yoohooplugins.com
*/
@andrewlimaza
andrewlimaza / give-access-to-all-posts-for-certain-members.php
Created June 22, 2018 10:48
Give access to membership for all restricted posts.
<?php
/**
* Give access to all members regardless if they have access to the current post or not.
* Add this code to your PMPro Customizations - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function give_access_to_all_pmpro_members_example( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
if ( pmpro_hasMembershipLevel( array( 7, 8, 9, 10 ) ) ) {
$hasaccess = true;
}
@andrewlimaza
andrewlimaza / show-icon-based-on-membership-access.php
Created June 21, 2018 09:36
Show icon based on level access and posts
<?php
/**
* This will add an image to the top of each post based on if a user has access to that post or not.
* Add the code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function show_icon_based_on_membership_access( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
if ( ! empty( $post_membership_levels ) ) {
// check if the user has access for a restricted post.
@andrewlimaza
andrewlimaza / pmpro-select-membership-duration.php
Last active February 19, 2019 17:09 — forked from travislima/pmpro-select-membership-duration.php
Allows customers to select membership duration at checkout. Adjusts the amount charged and expiration date of the membership accordingly.
<?php
/*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Allows customers to select membership duration at checkout. Adjusts the amount charged and expiration date of the membership accordingly.
* Requires the Paid Memberships Pro Register Helper Add On to be installed and activated in order to work - https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
*/
function my_pmprorh_init() {
@andrewlimaza
andrewlimaza / add-billing-to-add-member-and-profile.php
Created June 5, 2018 08:49
Add billing fields to Add Member Settings
<?php
/*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This will add billing fields to Add Member and the user's profile page.
*/
function add_billing_fields_to_add_member_profile() {
//check for register helper
if(!function_exists("pmprorh_add_registration_field"))
return;
@andrewlimaza
andrewlimaza / pmpro-rss-key-shortcode.php
Last active February 19, 2019 17:09
Shortcode to get Member RSS Key
<?php
/**
* Custom shortcode to get PMPro RSS Member Key.
* Example 1: [pmpro_rss_key] This will return the key for current member.
* Example 2: [pmpro_rss_key user_id="2"] This will return the key for user ID 2.
* Copy from line 3 onwards into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmprorss_shortcode_get_key( $atts ) {