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 | |
function wpf_dev_frontend_confirmation_message( $message, $form_data, $fields, $entry_id ) { | |
// Only run on my form with ID = 924 | |
if ( absint( $form_data[ 'id' ] ) !== 924 ) { | |
return $message; | |
} | |
// Email form field - ID #1 | |
$email_for_order_delivery = $fields[ '1' ][ 'value' ]; |
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 | |
/** | |
* Populate a field from another field on same form | |
* | |
* @link https://wpforms.com/developers/how-to-pre-populate-fields-in-the-same-form/ | |
*/ | |
add_action( 'wpforms_wp_footer_end', function() { | |
?> | |
<script> |
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 | |
// Filter: https://wpforms.com/developers/wpforms_field_select_choicesjs_config/ | |
//Dropdown Style must be set to Modern, see: https://a.supportally.com/i/xJag2i | |
function wpf_dev_modern_dropdown_position_bottom( $config, $forms ) { | |
// Change 18591 to an ID of your actual form or remove this condition to apply to all forms. | |
// See: https://wpforms.com/developers/how-to-locate-form-id-and-field-id/#form-id | |
if ( ! array_key_exists( 18591, $forms ) ) { | |
return $config; |
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( 'wpforms_entry_email_data', function ( $fields, $entry, $form_data ) { | |
// Bail early if form ID is not equal to 123 | |
if ( $form_data['id'] !== 123 ) { | |
return $fields; | |
} | |
// Unset field from notifications with field ID #2 | |
unset( $fields[2] ); | |
return $fields; |
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 | |
/** | |
* https://www.php.net/manual/en/function.substr-replace.php | |
* https://www.advancedcustomfields.com/resources/acf-load_value/ | |
*/ | |
/* Add target _blank to external links with ACF field */ | |
function add_blank_target_to_external_links($value, $post_id, $field) { | |
// Check if the link is external | |
if (preg_match('/https?:\/\/(?!' . preg_quote($_SERVER['HTTP_HOST']) . ')/i', $value)) { |
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 | |
/** | |
* Filter posts queried on ACF Relationship field based on Options page | |
* Filter : https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/ | |
* $post_id : The Options page 'post_id' setting specified in acf_add_options_page | |
* | |
*/ | |
//Modify which posts are queried based on Options page | |
add_filter('acf/fields/relationship/query/name=field_name', 'modify_rel_field_post_query', 10, 3); |
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 | |
/** | |
* https://www.advancedcustomfields.com/resources/acf_form/ | |
* | |
* Modify ACF Form Post Title Field Label | |
* @ default 'Post Title' | |
*/ | |
function acf_form_post_title_label( $field ) { | |
if ( is_page( 5 ) ) { // form on page ID 5. | |
$field['label'] = 'Product Name'; |
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 | |
/* | |
* Dynamically populate Gravity Forms Select field with ACF Select field Choices | |
* | |
* Add form ID at end of each filter to target a specific form | |
* | |
* Ref: https://docs.gravityforms.com/dynamically-populating-drop-down-fields/ | |
* | |
*/ |
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 | |
/** | |
* Prevent a field from being rendered | |
* Filter : https://www.advancedcustomfields.com/resources/acf-prepare_field/ | |
* | |
*/ | |
function hide_acf_field_on_admin( $field ) { | |
// Don't show this field if it contains a value. | |
if ( $field['value'] ) { |
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
$args = array( | |
'meta_query' => array( | |
'meta_key_1' => array( | |
'key' => 'product_price', // field_name_1 | |
'value' => array( 500, 1000 ), | |
'type' => 'numeric', | |
'compare' => 'BETWEEN', | |
), | |
'meta_key_2' => array( | |
'key' => 'product_type', //field_name_2 |
NewerOlder