Skip to content

Instantly share code, notes, and snippets.

View lubyagin's full-sized avatar

Александр lubyagin

View GitHub Profile
@andrewlimaza
andrewlimaza / my_pmpro_redirect.php
Created July 7, 2016 15:10
redirect PMPro sponsor/sponsee members on login
<?php
//copy lines 5 down into your theme's function.php or custom plugin.
function my_sponsored_redirect( $redirect_to, $request, $user){
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
if(pmprosm_isSponsoredLevel($user->membership_level->ID)){
//redirect goes here
@andrewlimaza
andrewlimaza / pmproc_redirect_member.php
Created July 29, 2016 14:32
redirect users away from home page if they are already logged in to a different page
<?php
//Copy lines 5 onwards into your PMPro custom plugin -> http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function pmproc_redirect_member(){
if( is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel() ){ //check if user is logged in, pmpro is installed and user has an active level.
global $current_user;
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); //get current users level ID
@andrewlimaza
andrewlimaza / my_logout_go_home.php
Created August 9, 2016 12:59
Redirect users to home page when logging out of WordPress
<?php
//copy lines 5 onwards into your active theme's function.php or custom plugin for code snippets.
function my_logout_go_home(){
wp_redirect( home_url() );
exit();
}
add_action( 'wp_logout', 'my_logout_go_home' );
@andrewlimaza
andrewlimaza / pmproc_redirect_non_member.php
Created August 15, 2016 14:49
redirect login for users that have an account but do not have a membership with PMPRO
<?php
//Copy line 5 down into your PMPRO Customizations plugin -> http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function pmproc_my_login_non_member(){
if( !pmpro_hasMembershipLevel() ){
wp_redirect('http://SOMEURL'); //Change this to the homepage URL for non-members.
exit;
}
}
@andrewlimaza
andrewlimaza / hide_discount_code_link.php
Last active February 19, 2019 23:25
Hide 'Do you have a discount code? Click here to enter your discount code.' from Paid Memberships Pro checkout page
@andrewlimaza
andrewlimaza / show_first_name_in_orders_page.php
Created September 12, 2016 14:51
extra fields to 'Orders' page for PMPRO
/*
* Add some custom fields to Membership>Orders page
*/
function my_pmpro_orders_extra_cols_header($theusers) {
?>
<th>Name</th>
<?php
}
add_action('pmpro_orders_extra_cols_header', 'my_pmpro_orders_extra_cols_header');
function my_pmpro_orders_extra_cols_body($theuser) {
@andrewlimaza
andrewlimaza / my_custom_dashboards.php
Last active February 19, 2019 23:25
Show 'report' widgets within the admin dashboard
<?php
//Copy the code below into your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function add_my_report_dashboard(){
if( ! defined( 'PMPRO_DIR' ) || ! current_user_can( 'manage_options' ) ){
return;
}
wp_add_dashboard_widget(
'pmpro_membership_dashboard', // Widget slug.
@andrewlimaza
andrewlimaza / add_message_after_credit_card_fields_pmpro.php
Created October 6, 2016 14:01
add message after credit card fields PMPro
<?php
//paste the following into your PMPro Customizations plugin (http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/) or your active theme's functions.php
function pmproc_add_my_message(){
_e( 'my custom text that will change.', 'pmpro');
}
add_action( 'pmpro_checkout_before_submit_button', 'pmproc_add_my_message' );
@andrewlimaza
andrewlimaza / decode_html_entities.js
Created October 7, 2016 09:38 — forked from DylanCodeCabin/decode_html_entities.js
Decodes html entities back to normal html
function decodeHtmlEntities(str) {
console.log(str);
var special = {
"&lt;" : "<",
"&gt;" : ">",
"&quot;" : '"',
"&apos;" : "'",
"&#039;" : "'",
"&amp;" : "&",
"\\" : ""
@andrewlimaza
andrewlimaza / add-image-to-level-title-levels.php
Last active February 19, 2019 23:24
Add an image to level title on levels.php pmpro
<?php
//copy lines 5 onwards into your PMPro Customizations plugin -> http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function edit_pmpro_level_title( $levels ){
foreach ( $levels as $level ) {
if ( $level->id == 1 || $level->id == 2 || $level->id == 3 ) {
$level->name = '<img src="some-image-url.png" alt-text="alt-text"/>' . $level->name;
}elseif ( $level->id == 4 || $level->id == 5 || $level->id == 6 ) {