Skip to content

Instantly share code, notes, and snippets.

@haleeben
haleeben / class-gf-stripe.php
Last active August 27, 2018 04:21
Gravity Forms Stripe Addon - Add filter to be able to set the plan_id before sending to Stripe
public function get_subscription_plan_id( $feed, $payment_amount, $trial_period_days, $currency = '' ) {
$safe_feed_name = preg_replace( '/[^a-z0-9_\-]/', '', strtolower( $feed['meta']['feedName'] ) );
$safe_billing_cycle = $feed['meta']['billingCycle_length'] . $feed['meta']['billingCycle_unit'];
$safe_trial_period = $trial_period_days ? 'trial' . $trial_period_days . 'days' : '';
$safe_payment_amount = $this->get_amount_export( $payment_amount, $currency );
/*
* Only include the currency code in the plan id when the entry currency does not match the plugin currency.
* Ensures the majority of plans created before this change will continue to be used.
add_action( 'transition_post_status', 'update_expired_post_meta', 10, 3 );
function update_expired_post_meta( $new_publish_status, $old_publish_status, $post ){
if( 'expired' == $new_publish_status ){
// Change the ACF field value to false
update_field( 'field_name', false, $post->ID );
}
@haleeben
haleeben / acf_readonly
Created January 31, 2016 04:14
Change a ACF field to readonly
add_filter('acf/load_field/name=field_name', 'acf_readonly' );
function acf_readonly( $field ) {
$field['readonly'] = 1;
return $field;
}
<?php
/**
* MOD: Better Limit Submissions Per Time Period by User or IP (without hiding form & spanning limit across a group of forms)
*
* Based On: http://gravitywiz.com/2012/05/12/limit-ip-to-one-submission-per-time-period
* Video: http://screencast.com/t/I11vWq02Qswn
*
* Note: This mod does not require the original snippet. Most of the parameters still function the same as the snippet it
* is based on. The only exception is the 'form_id' parameter which now accepts an array of form IDs rather than a single
* form ID.