Skip to content

Instantly share code, notes, and snippets.

View New0's full-sized avatar

Nicolas Figueira New0

View GitHub Profile
@New0
New0 / cf-reorder-csv-columns.php
Last active January 25, 2018 19:55
Caldera Forms Reorder CSV Columns
/**
* Apply the new columns order in Csv attached to email and CSV stored in admin
*/
add_filter( 'caldera_forms_email_csv_data', 'cf_reorder_csv_columns', 10, 2 );
add_filter( 'caldera_forms_admin_csv', 'cf_reorder_csv_columns', 10, 2 );
/**
* Reorder columns in Caldera Forms generated CSV file
*/
function cf_reorder_csv_columns( $csv_data, $form ){
<?php
/**
* Remove a field from the entry saved in the DB without removing it from the emails
*/
add_action( 'caldera_forms_submit_complete',function( $form, $referrer, $process_id, $entryid ){
unset( $form['fields']['fld_8768091'] );
Caldera_Forms_Save_Final::save_in_db( $form, $entryid );
@New0
New0 / cf-hide-submit-button-text.php
Created February 5, 2018 12:39
Hide Caldera Forms Submit button text
/*
* Hide Submit button text
* Zip this in custom plugin or theme's functions.php file
*/
add_action( 'wp_footer', function() {
echo '<script>
var btn = jQuery(".caldera-grid .btn");
if (btn.length > 0) {
jQuery(btn).val("");
}
@New0
New0 / cf-easy-pods-autopopulated-labels.php
Last active February 7, 2018 17:08
Return pods CPT title as the label for a select field options autopopulated using easy pods.
<?php
/**
* Change which Pods field is used for the label of a Caldera Forms field autopopulated with the results of an Easy Pods for a specific Easy Pod.
*/
add_filter( 'caldera_forms_easy_pods_autopopulate_label_field', function( $label_field ){
$label_field = 'post_title';
return $label_field;
}, 10 );
@New0
New0 / cf-entries-with-the-content-filter-hook.php
Created February 12, 2018 15:54
Use the the_content filter hook to display Caldera Forms entries
<?php
add_filter( 'the_content', function() {
//Replace the number with the page ID to display entries on
if ( is_page('2' ) ) {
require_once( CFCORE_PATH . 'classes/admin.php' );
//Be sure to set the correct form ID below
$form_id = 'CF5a5e8452c6f82';
//get all entires (page 1 with 9999999 entries per page should do it:)
@New0
New0 / cf-save-file_field-as-acf-gallery.php
Created February 19, 2018 14:34
Get data of a Caldera Forms multiple files field and save the files in an ACF gallery custom field
@New0
New0 / caldera_forms_submit_post_process-get-and-change.php
Created February 20, 2018 11:26 — forked from Shelob9/caldera_forms_submit_post_process-get-and-change.php
Example code for action that runs after Caldera Forms submission is processed, but before it is saved. For more information see: https://calderaforms.com/doc/caldera_forms_submit_post_process/
<?php
add_action( 'caldera_forms_submit_post_process', function( $form, $referrer, $process_id, $entry_id ){
//make sure to set your field ID here.
$field_id = 'fld_123456';
//Get value of a field
$field_value = Caldera_Forms::get_field_data( $field_id, $form , $entry_id);
//check value
if( in_array( $field_value, array( 'Roy', 'Shawn' )) ){
@New0
New0 / var_dump_post_meta.php
Last active February 22, 2018 07:56
Var dump the value of a post meta data
<?php
add_filter('the_content', function( $content ) {
//Replace 1 with the page ID you want to test in and the custom_field_name with your own
$page_id = '1';
$key = 'custom_field_name';
if( is_page( $page_id ) ) {
var_dump( get_post_meta( $page_id, $key) );
}
return $content;
@New0
New0 / CF-filters-setting-pro-api-keys.php
Created February 22, 2018 08:11
Set Caldera Forms Pro API keyes in a custom plugin or the functions.php file of the theme.
<?php
add_filter( 'caldera_forms_pro_get_public_key', function(){
return '0000-0000-000000000-0000';
});
add_filter( 'caldera_forms_pro_get_secret_key', function(){
return '0000-0000-000000000-0000';
});
@New0
New0 / cf-replyto-all-recipients.php
Last active February 22, 2018 20:30
Set the Reply to email addresses to match all tge recipients email addresses (will take recipients of conditional recipients processor)
<?php
add_filter( 'caldera_forms_mailer', function( $mail, $data, $form ) {
//MAKE SURE TO CHANGE FORM ID
if( "CF5a5e8452c6f82" == $form[ 'ID' ] ) {
//If Pro NOT activated
$mail[ 'replyto' ] = $mail[ 'recipients' ];
//IF Pro Activated
//$mail[ 'from' ] = $mail[ 'recipients' ];
}
return $mail;