functions - Modify gform_other_choice_value for specific form and specific field in Gravity Forms

I am looking to change the "other" text for a single specific field on a specific form in Gravity Forms.It see

I am looking to change the "other" text for a single specific field on a specific form in Gravity Forms.

It seems gform_other_choice_value does not work the way some of the other Gravity Forms filters work in that adding the form ID and field ID does not target the specific field, such as for field number 142 on form number 27 - gform_other_choice_value_27_142

How the form field currently looks

What I need

The Gravity Forms documentation (/) shows how to change "Other" wording for all forms, but not a specific field on a specific form.

I need to target a specific field on a specific form, because I will have multiple fields of this type within this single form, as well as many different forms that use "Other" throughout the website.

(Ultimately, I would also like the "Other" field to be the first option, rather than the last, but that's the next step after this - Make "Other" the first option for a radio button field in Gravity Forms)

I am looking to change the "other" text for a single specific field on a specific form in Gravity Forms.

It seems gform_other_choice_value does not work the way some of the other Gravity Forms filters work in that adding the form ID and field ID does not target the specific field, such as for field number 142 on form number 27 - gform_other_choice_value_27_142

How the form field currently looks

What I need

The Gravity Forms documentation (https://docs.gravityforms/gform_other_choice_value/) shows how to change "Other" wording for all forms, but not a specific field on a specific form.

I need to target a specific field on a specific form, because I will have multiple fields of this type within this single form, as well as many different forms that use "Other" throughout the website.

(Ultimately, I would also like the "Other" field to be the first option, rather than the last, but that's the next step after this - Make "Other" the first option for a radio button field in Gravity Forms)

Share Improve this question edited May 21, 2020 at 21:28 Travis Pflanz asked May 21, 2020 at 17:15 Travis PflanzTravis Pflanz 1,9535 gold badges31 silver badges57 bronze badges 1
  • I am not much of a dev, so specific code examples will help much more than replies discussing general concepts. – Travis Pflanz Commented May 21, 2020 at 17:16
Add a comment  | 

1 Answer 1

Reset to default 1

The second parameter is the field which contains the form ID to which it belongs and its own ID so you can target a specific form/field like so:

add_filter( 'gform_other_choice_value', function( $placeholder, $field ) {
    // Update "123" to your form ID and "4" to your field ID.
    if ( $field->formId == 123 && $field->id == 4 ) {
        $placeholder = 'Your custom placeholder';
    }
    return $placeholder;
}, 10, 2 );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742411954a4438992.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信