<?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; | |
}); |
<?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); |
<?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