LLMS_Forms::get_field_by( array[] $fields, string $key, mixed $val, string $return = 'field' )

Retrieve a field item from a list of fields by a key/value pair.

Parameters Parameters


(array[]) (Required) List of LifterLMS Form Fields.


(string) (Required) Setting key to search for.


(mixed) (Required) Setting valued to search for.


(string) (Optional) Determine the return value. Use "field" to return the field settings array. Use "index" to return the index of the field in the $fields array.

Default value: 'field'

Top ↑

Return Return

(array|int|false) false when the field isn't found in $fields, otherwise returns the field settings as an array when $return is "field". Otherwise returns the field's index as an int.

Top ↑

Source Source

File: includes/forms/class-llms-forms.php

	public function get_field_by( $fields, $key, $val, $return = 'field' ) {

		foreach ( $fields as $index => $field ) {
			if ( isset( $field[ $key ] ) && $val === $field[ $key ] ) {
				return 'field' === $return ? $field : $index;

		return false;


Top ↑

Changelog Changelog

Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.