Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / show_login_form.php
Last active February 19, 2019 23:24
Paid Memberships Pro - Show login form when members are logged out (simple example)
<?php
//copy lines 4 - 9 into custom plugins file or functions.php
function pmpro_show_login_form(){
//show a simple login form if users are logged out and a post/page requires membership
return wp_login_form();
}
add_filter('pmpro_not_logged_in_text_filter', 'pmpro_show_login_form');
@andrewlimaza
andrewlimaza / pmpro-hide-from-dir-rh.php
Last active May 24, 2023 07:39
PMPRO add Hide from Directory option to checkout page
<?php
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
//define the fields
@andrewlimaza
andrewlimaza / change-user-role-on-cancel-pmpro.php
Last active February 19, 2019 23:24
Assign a new WP user role when a user cancels their membership in Paid Memberships Pro
<?php
//Please copy line 5-22 into your active themes functions.php or custom plugin
//code to assign specific WP user role when cancelling
function my_pmpro_after_cancel_change_role($level_id, $user_id)
{
//get user object
$wp_user_object = new WP_User($user_id);
@andrewlimaza
andrewlimaza / change-default-checkout-button-pmpro.php
Last active July 11, 2023 08:12
Change default checkout button text for Paid Memberships Pro
<?php
//copy lines 5 - 20 to your active theme's functions.php or custom plugin. (edit line 11 to change text of button).
function my_pmpro_change_default_button_text( ){
//copy over HTML code from checkout.php to keep styling and simply change the text value to 'Create Account'
?>
<span id="pmpro_submit_span">
<input type="hidden" name="submit-checkout" value="1" />
@andrewlimaza
andrewlimaza / members_information_example.php
Last active February 19, 2019 23:24
Display members information example for Paid Memberships Pro
<?php
//copy lines 5-19 to your active themes functions.php file or custom plugin
//use the shortcode [members_details] to show information on your post/page
function pmpro_members_details_shortcode( $atts ){
if(is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel()){
global $current_user;
$user_name = $current_user->display_name;
$level_name = $current_user->membership_level->name;
@andrewlimaza
andrewlimaza / pmpro-change-default-country.php
Last active October 11, 2022 18:40
PMPRO change default country
<?php
//copy lines 5 - 12 into your theme's functions.php or custom plugin
function filter_pmpro_default_country( $default_country ) {
// Set country code to "AU" for Australia.
$default_country = "AU";
return $default_country;
}
@andrewlimaza
andrewlimaza / my_pmpro_hide_wp_feed.php
Created June 2, 2016 14:26
Hide PMPro activity feed for non-admins
<?php
//copy lines 5 - 14 into your active theme's functions.php or custom plugin.
function my_pmpro_remove_dashboard_widget(){
//check if user is not admin, then remove meta boxed
if( !current_user_can('manage_options') ) {
//remove default WP dashboard activity
remove_meta_box('dashboard_activity', 'dashboard', 'normal');
//remove PMPRO dashboard activity
@andrewlimaza
andrewlimaza / hide_my_admin_pages.php
Created June 3, 2016 13:40
Hide administrative menu icons for non-administrators
<?php
/*
This will hide all default menu links inside your WP dashboard. You are able to hide custom pages by adding 'remove_menu_page(<custom_post_url>); inside the function'
Copy lines 10-28 into your active theme's function.php or custom plugin.
*/
function remove_my_menu_pages() {
@andrewlimaza
andrewlimaza / page.php
Created June 14, 2016 14:30
Paid Memberships Pro content restriction for Muffin Builder plugin
<?php
/**
* The template for displaying all pages.
*
* Please create this as a custom page template in WordPress by simply adding this (page.php) to your active child theme's directory.
*
* @package Betheme
* @author Muffin group
* @link http://muffingroup.com
*/
@andrewlimaza
andrewlimaza / my_pmpro_logout_on_register.php
Last active August 24, 2022 15:19
Logout and redirect users after successfully signing up using PMPRO
<?php
//copy lines 5-10 to your active theme's functions.php or custom PMPro plugin
function my_logout_after_register(){
wp_logout();
wp_redirect( '<SOME URL>' ); exit; //edit this line with the URL for users to be redirected to.
}
add_action('pmpro_confirmation_url', 'my_logout_after_register');