Skip to content

Instantly share code, notes, and snippets.

View New0's full-sized avatar

Nico Figueira Mahe New0

View GitHub Profile
<?php
/**
* Change Caldera Forms Stripe Payment Amount
*/
add_filter( 'cf_stripe_charge_args', function( $args, $config, $form ){
//change charge amounts to $10. Amount is in cents.
$args["line_items"][0][ "amount" ] = 1000;
return $args;
}, 10, 4 );
<?php
//this applies change when creating plans
add_filter( 'cf_stripe_recurring_args', 'my_cf_stripe_recurring_filter', 10, 2 );
//this applies change when creating one time payments
add_filter( 'cf_stripe_charge_args', 'my_cf_stripe_single_filter', 10, 2 );
//this is the callback to change arguments sent to API
//Be careful not to set a field that isn't supported or the API will reject the charge.
//Description for single payments
@New0
New0 / cf-show-pro-ui.php
Last active January 26, 2023 00:49
Show Pro settings in Caldera Forms if disconnected ( this can be activated as a WordPress plugin using the Download Zip button )
<?php
/**
* Plugin Name: CF Show Pro UI
* Description: Show Caldera Forms pro settings
* Author: Caldera Forms
**/
//Force Pro settings to show
add_filter('caldera_forms_show_pro_ui', '__return_true');
@New0
New0 / cf-user-entry-viewer.php
Created January 7, 2020 16:24
Allow a precise user to read form the caldera forms entry viewer
<?php
/*
* This will allow a user with ID 2 to view the entry viewer even without the manage_optiuons capability
* REPLACE 2 by the correct user ID
*/
add_filter('caldera_forms_manage_cap', function( $cap, $context, $form ){
if( is_user_logged_in() ){
$user_id = get_current_user_id();
@New0
New0 / cf-caldera_forms_field_attributes-ssn-pattern.php
Created January 7, 2020 20:20
Social security number pattern for Caldera Forms single line text fields
<?php
/*
* Validates fields only using a Social security number pattern like 999-99-999
* EDIT FIELDS IDS TO BE VALIDATED "fld_5675945", "fld_1648505"
*/
add_filter( 'caldera_forms_field_attributes', function( $attrs, $field, $form ){
$fields = ["fld_5675945", "fld_1648505"];
if( in_array( $field['ID'], $fields ) ){
$attrs[ 'pattern' ] = '^\d{3}-\d{2}-\d{4}';
}
@New0
New0 / cf-stripe-pi-description.php
Last active January 30, 2020 13:52
Display a description for the payment on the Stripe interface. Requires Caldera Forms Stripe add-on
<?php
/*
* Plugin Name: CF Stripe Payment description
* Author: Nicolas Figueira
* Descriptipon: Display the description in the payments on the Stripe dashboard
*
*/
add_filter( 'cf_stripe_charge_args', function( $args, $config, $form ){
//The description can also be set to be different from the processor's settings
@New0
New0 / cf-set-browser-details.php
Created February 6, 2020 11:18
Set the browser details "HTTP_USER_AGENT" in a Caldera Forms hidden field
<?php
/*
* Set the HTTP_USER_AGENT as the value of a hidden field during submission
* In this case the hidden field ID is fld_7526079, that needs to be edited
*/
add_filter( 'caldera_forms_process_field_hidden', function( $value, $field ) {
//Change your field ID here
if( $field['ID'] === "fld_7526079" ){
$value = $_SERVER['HTTP_USER_AGENT'];
@New0
New0 / cf-remove-backslash.php
Last active February 14, 2020 16:01
Remove backslash from parsed data of bracket magic tags in Caldera Forms
<?php
/*
* This is very basic, you may want to target a precise $form, $magics or type of $value using conditions.
*/
add_filter( 'caldera_forms_do_field_bracket_value', function($value, $magics, $entry_id, $form ){
return implode("",explode("\\",$value));
}, 10, 4);
@New0
New0 / cf-html5pattern-example.php
Created February 19, 2020 15:40
Set an html5 pattern on a Caldera Forms field
<?php
/*
* HTML5 Pattern to limiot input field to 8 alphanumeric (only capitals) characters
*/
add_filter( 'caldera_forms_field_attributes', function($attrs, $field){
//IMPORTANT - Change your field ID
if ( 'fld_1234' === $field[ 'ID'] ) {
$attrs[ 'pattern' ] = '[A-Z0-9]{8}';
}
return $attrs;
@New0
New0 / cf-remove-tags-entry-csv-export.php
Last active March 11, 2020 11:08
Remove HTML Tags from the Entry data exported to CSV from admin
<?php
/**
* Plugin Name: CF Remove CSV Html
* Description: This Removes the HTML tags from the entries data exported to CSV file
*/
add_filter('caldera_forms_admin_csv', function( $csv_data, $form){
//Uncomment and set the correct Form ID to target a precise Form
//if($form['ID'] === 'CF5d6f65f0e87f4'){
foreach( $csv_data['data'] as $entry_ID => $entry ){
if(is_array($entry) === true){