This file contains 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
<? | |
// Change 'XXX' to your form id | |
$location_form_id = XXX; | |
add_filter( 'gform_pre_render_'.$location_form_id, 'limit_choices' ); | |
add_filter( 'gform_pre_validation_'.$location_form_id, 'limit_choices' ); | |
add_filter( 'gform_pre_submission_'.$location_form_id, 'limit_choices' ); | |
add_filter( 'gform_pre_submission_filter_'.$location_form_id, 'limit_choices' ); | |
add_filter( 'gform_admin_pre_render_'.$location_form_id, 'limit_choices' ); | |
function limit_choices( $form ) { |
This file contains 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 | |
form_id = 1; | |
add_action("gform_post_submission_".$form_id, "add_new_post_featured_image"); | |
function add_new_post_featured_image($entry){ | |
$title_id = 1; | |
$content_id = 2; | |
$file_id = 3; | |
$new_post = array( | |
'post_title' => $entry[$title_id], |
This file contains 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 | |
/* *** replace "your_parameter" with the parameter in the advanced tab | |
https://docs.gravityforms.com/using-dynamic-population/ */ | |
add_filter( 'gform_field_value_your_parameter', 'my_custom_population_function' ); | |
function my_custom_population_function( $value ) { | |
return 'boom!'; | |
} | |
/*Use this for a real estate form */ |
This file contains 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 fields from ACF to columns in admin view **** | |
https://pluginrepublic.com/add-acf-fields-to-admin-columns/ | |
CHANGE | |
- manage_model_posts_columns (replace "model" with post type slug) | |
- manage_model_posts_custom_column (replace "model" with post type slug) | |
- model_order (replace with ACF slug) | |
*/ | |
function add_acf_columns ( $columns ) { | |
return array_merge ( $columns, array ( |
This file contains 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/dynamically-populate-a-select-fields-choices/#example-2 | |
*** CHANGE *** | |
- child_field (this is the dropdown inside the repeater field) | |
- post_slug | |
*/ | |
function acf_pre_populate_repeater_dropdown ( $field ) { | |
$field['choices'] = array(); | |
$args = array('post_type' => 'post_slug'); |
This file contains 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://docs.gravityforms.com/gform_pre_render/#3-populate-field-with-values-from-earlier-page | |
add_filter( 'gform_pre_render_8', 'populate_user_dropdown_info' ); | |
add_filter( 'gform_pre_validation_8', 'populate_user_dropdown_info' ); | |
add_filter( 'gform_pre_submission_filter_8', 'populate_user_dropdown_info' ); | |
//add_filter( 'gform_admin_pre_render_8', 'populate_user_dropdown_info' ); | |
function populate_user_dropdown_info( $form ) { | |
$current_page = GFFormDisplay::get_current_page( $form['id'] ); |
This file contains 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
add_action( 'gform_post_submission_6', 'update_user_info', 10, 2 ); | |
function update_user_info( $entry, $form ) { | |
$userid = rgar($entry,'6'); | |
$email = rgar($entry,'5'); | |
$first_name = rgar($entry,'1.3'); | |
$last_name = rgar($entry,'1.6'); | |
$company = rgar($entry,'4'); | |
$address = rgar($entry,'3'); | |
$password = rgar($entry,'7'); | |
$user_id = wp_update_user( array( |
This file contains 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
add_filter( 'gform_pre_render_6', 'populate_user_info' ); | |
add_filter( 'gform_pre_validation_6', 'populate_user_info' ); | |
add_filter( 'gform_pre_submission_filter_6', 'populate_user_info' ); | |
add_filter( 'gform_admin_pre_render_6', 'populate_user_info' ); | |
function populate_user_info( $form ) { | |
$userid = sanitize_text_field($_GET['userid']); | |
foreach ( $form['fields'] as &$field ) { | |
if ($field->type == 'name'){ | |
$field->inputs[1]['defaultValue'] = get_first_name($userid); |
This file contains 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
// https://docs.gravityforms.com/dynamically-populating-drop-down-fields/ | |
/* Instructions | |
- Create a form | |
- Add a "Dropdown" field | |
- Add "populate-posts" as the CSS class | |
*/ | |
add_filter( 'gform_pre_render_51', 'populate_posts' ); | |
add_filter( 'gform_pre_validation_51', 'populate_posts' ); |
This file contains 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 | |
//* Do NOT include the opening php tag | |
//* Enqueue Dashicons | |
//* CHECK YOUR functions.php FILE FIRST! | |
add_action( 'wp_enqueue_scripts', 'b3m_enqueue_dashicons' ); | |
function b3m_enqueue_dashicons() { | |
wp_enqueue_style( 'dashicons' ); | |
} |