Skip to content

Instantly share code, notes, and snippets.

View JarrydLong's full-sized avatar

Jarryd Long JarrydLong

  • Paid Memberships Pro
  • South Africa
  • 14:46 (UTC +02:00)
  • X @jarrydlong
View GitHub Profile
@JarrydLong
JarrydLong / WP Google Maps
Created August 28, 2017 18:49
Select a specific category based on Cat ID on page load
var wpgmza_open_cat = wpgmza_getUrlVars()["catid"];
jQuery(document).ready(function(){
if( jQuery('.wpgmza_checkbox').length > 0 && typeof wpgmza_open_cat !== 'undefined' ){
setTimeout(function(){
jQuery("#wpgmza_cat_checkbox_"+wpgmza_open_cat).click();
}, 800);
@JarrydLong
JarrydLong / WP Google Maps
Created August 31, 2017 19:56
Reset the map to the original zoom level when closing the info window
google.maps.event.addListener(infoWindow[wpmgza_marker_id],'closeclick',function(){
MYMAP[map_id].map.setZoom(parseInt(wpgmaps_localize[map_id]['map_start_zoom']));
});
@JarrydLong
JarrydLong / Vlad
Created September 4, 2017 06:19
HTML to assign the Live Chat Window to on page load
<div id='inpage_wplc_chat'></div>
@JarrydLong
JarrydLong / contact-form-ready
Created September 4, 2017 16:57
Enables form validation for all fields. Add the valid variable to the conditional statement before submitting
var valid = 0;
jQuery.each( jQuery("#wpcf_nd .text-input, #wpcf_nd .text-area"), function(){
if( jQuery(this).val() === "" ){
jQuery(this).css("border", "1px solid red");
valid++;
}
});
@JarrydLong
JarrydLong / init_test_stripe.php
Created February 21, 2020 08:22 — forked from strangerstudios/init_test_stripe.php
Test a Stripe Webhook Event with WordPress and Paid Memberships Pro
/*
Test Stripe webhook events
Add to a custom plugin, then visit /?teststripe=1
*/
function init_test_stripe() {
if(!empty($_REQUEST['teststripe'])) {
$_REQUEST['event_id'] = 'evt_9ktqwT5xFlKNOp'; //EDIT THIS to be the ID of an actual recurring payment event in your account
require_once(PMPRO_DIR . "/services/stripe-webhook.php");
@JarrydLong
JarrydLong / pmprorh-init-buddypress-fields.php
Last active February 24, 2020 10:36 — forked from pbrocks/pmprorh-init-buddypress-fields.php
Example of defining PMPro Register Helper Fields Synchronized to BuddyPress XProfile Fields
<?php
/**
* Based on the Register Helper example.
* We've added a "buddypress" option for each field
* set to the XProfile name we used when setting up
* the fields in the BuddyPress extended profile.
* If the PMPro BuddyPress Add On is activated
* then the fields will be synchronized.
* Register Helper: https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
* PMPro BuddyPress: https://www.paidmembershipspro.com/add-ons/buddypress-integration/
<?php
/**
* Render the extra profile fields on the backend
*/
function extra_user_profile_fields( $user ) { ?>
<h3><?php _e("Extra profile information", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="external_username"><?php _e("External Username"); ?></label></th>
@JarrydLong
JarrydLong / pmpro-remove-user-membership-order-data.php
Created March 16, 2020 15:15
Removes a user's membership and order data either by manually adding in a query param, or when deleting a user through /wp-admin/
<?php
/**
* Remove user data manually by adjusting the ID's in the array, or adding them into a
* query param by setting it to /?reset_test_accounts=true&accounts=2,3
* This works well if you've deleted the user accounts already and want to remove the
* first few users you'd initially tested with
*/
function pmpro_remove_test_accounts( $user_id = null ){
if( isset( $_REQUEST['reset_test_accounts'] ) && $_REQUEST['reset_test_accounts'] == 'true' ){
<?php
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user){
if( isset( $_REQUEST['discount_code'] ) && $_REQUEST['discount_code'] !== "" ){
$new_fields = array(
"DISCOUNTC" => $_REQUEST['discount_code'],
);
$fields = array_merge($fields, $new_fields);
UPDATE wp_pmpro_memberships_users SET enddate = "0000-00-00 00:00:00" WHERE membership_id = 15 AND status = "active"