Last active
December 2, 2017 17:26
-
-
Save Shelob9/d0f619668df94d82d9114c9178c6dfb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'caldera_forms_render_get_field', function( $field ) { | |
if( 'fld123456' == $field[ 'ID' ] ){ | |
$field[ 'config' ][ 'default' ] = esc_url_raw( caldera_forms_get_current_url() ); | |
} | |
return $field; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'caldera_forms_render_get_field', function( $field, $form ){ | |
if( 'dropdown' == $field[ 'type'] && ! empty( $field[ 'config' ][ 'option' ] ) ){ | |
//@TODO Change field name to the right user custom field | |
$meta = get_user_meta( get_current_user_id(), 'field_name', true ); | |
if ( ! empty( $meta ) ) { | |
foreach ( $field[ 'config' ][ 'option' ] as $option => $args ) { | |
if ( $meta == $args[ 'value' ] ) { | |
$field[ 'config' ][ 'default' ] = $option; | |
} | |
} | |
} | |
} | |
return $field; | |
}, 10, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'caldera_forms_render_get_field', function( $field ) { | |
if ( 'stores_in_pa' == $field[ 'slug' ] ) { | |
$stores = get_posts( array( 'post_type' => 'stores', 'meta_key' => 'state', 'meta_value' => 'PA' ) ); | |
if ( ! empty( $stores ) ) { | |
foreach( $stores as $store ) { | |
$field[ 'config' ][ 'option' ][ $store->ID ] = array( | |
'value' => $store->ID, | |
'label' => $store->post_title | |
); | |
} | |
} | |
} | |
return $field; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment