Skip to content

Instantly share code, notes, and snippets.

View lubyagin's full-sized avatar

Александр lubyagin

View GitHub Profile
@andrewlimaza
andrewlimaza / three-custom-fields.php
Created April 6, 2016 13:49
PMPRO Register Helper - 3 Custom fields
<?php
/*
Paste this code into active theme's functions.php or custom plugin.
*/
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
@andrewlimaza
andrewlimaza / pmpro-admin-only.php
Created April 8, 2016 13:49
PMPRO Register Helper Add on - Hide a field for admins only.
<?php
//paste lines 5-39 in your functions.php or custom PMPRO plugin
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
@andrewlimaza
andrewlimaza / show_login_form.php
Last active May 28, 2024 13:49
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 / 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 November 7, 2024 06:17
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( ){
global $pmpro_requirebilling;
?>
<span id="pmpro_submit_span">
<input type="hidden" name="submit-checkout" value="1" />
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Create Account', 'paid-memberships-pro'); } else { _e('Checkout and Continue', 'paid-memberships-pro');}?>" />
@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 / 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 / change_discount_code_text.php
Created June 24, 2016 09:58
PMPRO change discount code text to promotional code for checkout
<?php
// Copy lines 5-25 to your active theme's functions.php or custom plugin.
function change_discount_code_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Discount Code' :
$translated_text = __( 'Promotional Code', 'pmpro' );
break;
@andrewlimaza
andrewlimaza / my_pmpro_last_login.php
Last active February 19, 2019 23:24
PMPRO show when user's last logged in in the member's list
<?php
/**
* Add this code to your active theme's function.php or custom plugin. (Copy lines 6 - 33 only)
*/
function my_pmpro_last_login( $user_login, $theusers ) {
//get user meta 'my_pmpro_last_login' on login and add time() to it.
update_user_meta( $theusers->ID, 'my_pmpro_last_login', time() );
}
add_action( 'wp_login', 'my_pmpro_last_login', 10, 2 );