Skip to content

Instantly share code, notes, and snippets.

View greathmaster's full-sized avatar
🧐

Hersha Venkatesh greathmaster

🧐
  • San Francisco, Bay Area
View GitHub Profile
@greathmaster
greathmaster / pmpro-pre-select-paypal-express.php
Created October 30, 2015 16:52
Pre select the PayPal Express payment option (vs credit card) when using PayPal Website Payments Pro
/*
* Pre select the PayPal Express payment option (vs credit card) when using PayPal Website Payments Pro
*/
function pre_select_paypal()
{?>
<script>
jQuery(document).ready(function(){jQuery("input[name=gateway][value='paypalexpress']").click();});
</script><?php
}
@greathmaster
greathmaster / pmpro-display-membership-level-for-posts.php
Created November 5, 2015 16:18
Displays membership level ids a post is assigned to under the manage posts page.
function my_pmpro_post_membership_levels_header($defaults)
{
$defaults['membership_levels'] = 'Membership Levels';
return $defaults;
}
function my_pmpro_post_membership_levels($column_name, $post_ID)
{
if ($column_name == 'membership_levels')
{
@greathmaster
greathmaster / pmpro-show-next-payment-date.php
Created November 5, 2015 17:24
Echo the next payment date for a member.
function my_pmpro_show_next_payment_date()
{
$next_date = pmpro_next_payment(NULL, "success", "date_format");
if($next_date)
echo $next_date;
else
echo "---";
}
@greathmaster
greathmaster / pmpro-register-helper-example-with-select-themes.php
Created November 14, 2015 04:49
Create select dropdown with themes for PMPro Register Helper
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
$fields = array();
@greathmaster
greathmaster / pmpro-custom-subscription-delay.php
Created November 14, 2015 06:31
Delay start of subscription to first of next month if current day of the month is less than the cut off day. Otherwise start on the first of next next month.
/*
Delay start of subscription to first of next month if current day of the month is less than the cut off day.
Otherwise start on the first of next next month. For example: A member signs up on November 6, and the ‘cutoff’ date is Nov 15.
Then they will be charged on Dec 1. But someone who signs up on Nov 17 will be charged on January 1.
Must have PMPro Subscription Delays (http://www.paidmembershipspro.com/add-ons/plus-add-ons/subscription-delays/)
installed and activated
*/
function my_pmprosd_modify_start_date($start_date, $order, $subscription_delay)
{
@greathmaster
greathmaster / pmpro-change-start-date.php
Created November 14, 2015 06:45
Change the start date of a membership.
function my_pmpro_member_startdate($start_date, $user_id, $level_id)
{
$date = strtotime("10 December 2015");
return $date;
}
add_filter('pmpro_member_startdate', 'my_pmpro_member_startdate', 10, 3);
@greathmaster
greathmaster / hide-toolbar-option-for-themed-profiles.css
Created November 17, 2015 18:49
Hide "Show Toolbar when viewing site" on themed profiles with Theme My Login
/*
Use Hide Admin Bar from Non-Admins(https://wordpress.org/plugins/hide-admin-bar-from-non-admins/)
to ensure users don't see the admin bar. The code below will hide "Show Toolbar when viewing site"
on themed profiles with Theme My Login.
*/
tr.tml-user-admin-bar-front-wrap {
display: none;
}
@greathmaster
greathmaster / profile.php
Created November 20, 2015 20:37
Custom profile for PMPro Member Directory. Allows <br> tags in the bio.
<?php
/*
This shortcode will display the profile for the user ID specified in the URL and additional content based on the defined attributes.
*/
function pmpromd_profile_preheader()
{
global $post, $pmpro_pages, $current_user;
if(!empty($post->ID) && $post->ID == $pmpro_pages['profile'])
{
/*
@greathmaster
greathmaster / pmpro-allow-hidden-level-checkout.php
Last active November 24, 2015 16:05
Show levels and allow checkout (renewal) for hidden levels if the user already has that level.
/*
Show levels which are hidden on the level page if the user already has that level.
*/
function my_pmpro_levels_array($levels)
{
$member_level = pmpro_getMembershipLevelForUser($current_user->ID);
$check = false;
foreach($levels as $level)
{
@greathmaster
greathmaster / exclude_category_from_pmpro_limit_views.php
Last active November 26, 2015 02:45
Excludes a category from being counted with PMPro Limit Post Views
function exclude_category_from_pmpro_limit_views()
{
global $post;
if(has_category("events", $post) && is_user_logged_in())
{
add_filter("pmpro_has_membership_access_filter", "__return_true");
}
}