Skip to content

Instantly share code, notes, and snippets.

View New0's full-sized avatar

Nicolas Figueira New0

View GitHub Profile
@New0
New0 / caldera_forms_api_allow_entry_view-1.php
Last active October 18, 2019 10:31 — forked from Shelob9/caldera_forms_api_allow_entry_view-1.php
Code examples for caldera_forms_api_allow_entry_view filter to change who can see Caldera Forms front-end entry viewer and corresponding REST API endpoint
<?php
/**
* Allow all requests to read entries of form with ID CF123567
*
* For API endpoint that powers front-end entry viewer.
*/
add_filter( 'caldera_forms_api_allow_entry_view', function( $allowed, $form_id, WP_REST_Request $request ){
if( 'CF123567' === $form_id ){
return true;
}
@New0
New0 / caldera_forms_field_attributes-add-attr.php
Last active September 19, 2019 10:54 — forked from Shelob9/caldera_forms_field_attributes-add-attr.php
Examples of how to use the Caldera Forms filter caldera_forms_field_attributes to modify Caldera Forms input elements. See: https://calderaforms.com/doc/caldera_forms_field_attributes/
<?php
add_filter( 'caldera_forms_field_attributes', function( $attrs, $field, $form ){
if( 'button' === Caldera_Forms_Field_Util::get_type( $field, $form ) ){
$attrs[ 'data-form-id' ] = $form[ 'ID' ];
}
return $attrs;
}, 20, 3 );
<?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[ 'amount' ] = 1000;
return $args;
}, 10, 4 );
@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 / track-entry-id-by-user.php
Last active September 13, 2018 14:31 — forked from Shelob9/track-entry-id-by-user.php
Track Caldera Forms entry ID in user meta so form can be used as editor for previous submission https://calderaforms.com/doc/edit-caldera-forms-entries/
<?php
/**
* On form load, check for a saved entry for current user
*/
add_filter( 'caldera_forms_render_entry_id', function ( $entry_id, $form ){
//change form ID to match your form
if( 'CF1234567' == $form[ 'ID' ] && get_current_user_id() ){
$saved_entry_id = get_user_meta( get_current_user_id(), 'form_entry_id' );
if( 0 < absint( $saved_entry_id ) ){
$entry_id = $saved_entry_id;