Skip to content

Instantly share code, notes, and snippets.

View New0's full-sized avatar

Nico Figueira Mahe New0

View GitHub Profile
@New0
New0 / cf-dynamic-braintree-plans.php
Last active March 4, 2020 18:10
Dynamic plans in Braintree processor for Caldera Forms.
<?php
/**
* Plugin Name: CF Dynamic Braintree Plans
* Description: Set a different Braintree Plan ID based on a fields value, using one Braintree processor
* Author: New0
*/
/* Create a Dropdown select field and set the values of each otpion with the ID of a Braintree Plan. T
Then copy and paste this dropdown select field in the code below */
@New0
New0 / cf-check-filetype-error.php
Last active March 4, 2020 20:02
For Caldera Forms, check filetype errors and prevent page navigation if detected
<?php
/**
* Plugin Name: CF File Error On Page Nav
* Description: Check if a File Type error is displayed during Next page button click and prevents navigation if found.
* Author: New0
*/
// Add jQuery to document footer
add_action('wp_footer', function(){
?>
@New0
New0 / cf_custom_featured_cf2.php
Last active March 17, 2020 13:43
Set a featured image via an advanced file field 2.0 and Save as post type processor in Caldera Forms.
@New0
New0 / cf-render-notice-data.php
Created March 20, 2020 11:43
Print data from the Caldera Forms submission the the render notice
<?php
/**
* Plugin Name: CF Render Notice data
* Description: Filter Caldera Forms render notice data and use data from the form submission.
* Author: New0 Nico Figueira
*/
add_filter( 'caldera_forms_render_notices', function( $notices ){
//Set the correct corresponding field ID we want the data from/
@New0
New0 / cf-autoresponse-submission-data.php
Created April 10, 2020 12:16
Example how to get submission data in 'caldera_forms_autoresponse_mail' filter hook.
<?php
/**
* Filter the email sent via the autoresponse processor
*/
add_filter( 'caldera_forms_autoresponse_mail', function( $email_message, $config, $form, $entry_id){
$entry = Caldera_Forms::get_entry($entry_id,$form);
return $email_message;
}, 10, 4 );
@New0
New0 / cf-pdf-template.html
Last active April 17, 2020 09:59
HTML template example that can be used in the editor for Caldera Forms emails and PDF Submissions
<div style="text-align: center; font-size: 2em;">
<div style="border: 5px solid #b3e6ff; padding: 2% 3% 2% 3%; max-width: 650px; margin: 1% auto 1% auto; background-color: #b3e6ff; color: white;">My PDF Submission</div>
<div></div>
</div>
<div style="text-align: left; font-size: 1.2em;">
<div style="border: 2px solid #b3e6ff; padding: 2% 3% 2% 3%; max-width: 650px; margin: 1% 10% 1% 10%; background-color: white; color: black;">
<p style="text-align: center;">
Hello %first_name% %last_name%
<?php
/**
* caldera_forms_api_allow_pdf_download
*
* Control how it is allowed to download the PDF files
*
* @param boolean $allowed
* @param array $request
*/
add_filter("caldera_forms_api_allow_pdf_download", function($allowed, $request ) {
@New0
New0 / cf-stripe-transients-durantion.php
Last active May 8, 2020 10:20
Set custom duration for Caldera Forms Stripe sessions to be correctly recorded ( since add-on version 1.4.11 )
<?php
/**
* Plugin Name: Stripe session transients duration
* Description: Customize duration for Form entries to be stored.
* Author: New0
*
*/
//Set the time in seconds ( here 15 * 60 converts to 15 minutes )
add_filter("cf_stripe_transients_status_duration", function() {
return 15 * 60;
@New0
New0 / cf-reset-form-stripe-cancelation.php
Last active May 21, 2020 09:57
Reset Form after Stripe transaction cancelled in Caldera Forms
<?php
/**
* Plugin Name: Caldera Forms manage Stripe cancelation
* Description: Dispay a link that resets the form when returning from Stripe cancellation.
* Plugin URL: https://gist.github.com/New0/65b1b0dc194c23703e935a0fc22268a1
* Author: New0
*/
add_filter( 'caldera_forms_pre_render_form', function( $html, $entry_id, $form ){
//Check if we come back from Stripe with cancelled status
@New0
New0 / cf-min-html5-date.php
Created May 26, 2020 15:00
Set the Caldera Forms text field with date Type to only allow future dates to be picked.
<?php
add_filter( 'caldera_forms_field_attributes', function( $attrs, $field ){
//EDIT FIELD ID
if( $field['ID'] === "fld_7194486" ){
$attrs[ 'min' ] = date("Y-m-d");
}
return $attrs;