LLMS_Form_Handler::get_fields( string $action, string $location, array $args = array() )

Retrieve fields for a given form.


Description Description

Ensures the form exists and that the current user can access the form.


Top ↑

Parameters Parameters

$action

(string) (Required) User action to be performed. Either "update" (for an existing user) or "registration" for a new user.

$location

(string) (Required) Form location ID.

$args

(array) (Optional) Additional arguments passed to the short-circuit filter.

Default value: array()


Top ↑

Return Return

(WP_Error|array[]) Array of LLMS_Form_Field arrays on success or an error object on failure.


Top ↑

Source Source

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

	protected function get_fields( $action, $location, $args = array() ) {

		$fields = LLMS_Forms::instance()->get_form_fields( $location, $args );

		// Form couldn't be located.
		if ( false === $fields ) {
			// Translators: %s = form location ID.
			return new WP_Error( 'llms-form-invalid-location', sprintf( __( 'The form location "%s" is invalid.', 'lifterlms' ), $location ), $args );

		} elseif ( 'account' === $location && 'update' !== $action ) {
			// No logged in user, can't update.
			return new WP_Error( 'llms-form-no-user', __( 'You must be logged in to perform this action.', 'lifterlms' ), $args );
		}

		return $fields;

	}


Top ↑

Changelog 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.