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
function clean($string) { | |
$string = str_replace(' ', '_', $string); // Replaces all spaces with hyphens. | |
$string = preg_replace('/[^A-Za-z0-9_]/', '', $string); // Removes special chars. | |
return preg_replace('/_+/', '_', $string); // Replaces multiple hyphens with single one. | |
} | |
echo clean("HAnn-a Jane##ll f. e"); // HAnna_Janell_f_e |
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 payment currency base from another field, when specific form is submitted. | |
*/ | |
add_action( 'gform_pre_submission_2', 'change_currency_' ); | |
function change_currency_( $form ) { | |
add_filter( 'gform_currency', function() { return rgpost('input_4'); } ); | |
} |
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
# Docs: https://docs.gravityforms.com/gform_display_product_summary/ | |
# Disable for all forms | |
add_filter( 'gform_display_product_summary', '__return_false' ); | |
# Disable for a specific form | |
add_filter( 'gform_display_product_summary', function( $display_product_summary, $field, $form, $entry ) { | |
return $form['id'] == 10 ? false : $display_product_summary; | |
}, 10, 4 ); |
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
{ | |
"USD": { | |
"symbol": "$", | |
"name": "US Dollar", | |
"symbol_native": "$", | |
"decimal_digits": 2, | |
"rounding": 0, | |
"code": "USD", | |
"name_plural": "US dollars" | |
}, |
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
# http://inlinedocs.gravityhelp.com/class-GFAPI.html | |
# https://docs.gravityforms.com/getting-started-with-the-gravity-forms-api-gfapi/ | |
# working code | |
# notes: we are to going to lists submitted entries of the current loggedin user. | |
$form_ids = [19, 20, 21, 22, 23, 24, 25, 26]; // accepts single or array of form id's. | |
$search_criteria = array( | |
'field_filters' => array( | |
'mode' => 'any', |
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( 'init', 'gta_rewrite_add_rewrites' ); | |
function gta_rewrite_add_rewrites() | |
{ | |
add_rewrite_rule('agent/?([^/]*)', 'index.php?pagename=agent&agentID=$matches[1]', 'top'); | |
} | |
add_filter('query_vars', 'gta_query_vars'); |
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
# References: | |
# https://docs.gravityforms.com/dynamically-populating-drop-down-fields/ | |
# https://docs.gravityforms.com/gf_field_select/ | |
add_filter( 'gform_pre_render_45', 'disable_ADA_ACA_transactions' ); | |
add_filter( 'gform_pre_validation_45', 'disable_ADA_ACA_transactions' ); | |
add_filter( 'gform_pre_submission_filter_45', 'disable_ADA_ACA_transactions' ); | |
add_filter( 'gform_admin_pre_render_45', 'disable_ADA_ACA_transactions' ); | |
function disable_ADA_ACA_transactions( $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
add_filter( 'edit_profile_url', 'custom_profile_url', 10, 3 ); | |
function custom_profile_url( $url, $user_id, $scheme ) { | |
if ( !current_user_can('subscriber') ) return; | |
return ''; | |
} | |
# IMPORTANT NOTES: What the function does above is removing the link on the Edit Profile if the current loggedin user role is `subscriber`. |