LLMS_Forms::get_free_enroll_form_fields( LLMS_Access_Plan $plan )
Retrieve an array of form fields used for the “free enrollment” form
Description Description
This is the "one-click" enrollment form used when a logged-in user clicks the "checkout" button from an access plan.
This function converts the checkout form to hidden fields, the result is that users with all required fields will be enrolled into the course with a single click (no need to head to the checkout page) and users who are missing required information will be directed to the checkout page.
Parameters Parameters
- $plan
-
(LLMS_Access_Plan) (Required) Access plan being used for enrollment.
Return Return
(array[]) List of LLMS_Form_Field settings arrays.
Source Source
File: includes/forms/class-llms-forms.php
'name' => 'llms_plan_id',
'type' => 'hidden',
'value' => $plan->get( 'id' ),
'data_store_key' => false,
);
/**
* Filter the list of LLMS_Form_Fields used to generate the "free enrollment" form
*
* @since 5.0.0
*
* @param array[] $fields List of LLMS_Form_Field settings arrays.
* @param LLMS_Access_Plan $plan Access plan being used for enrollment.
*/
return apply_filters( 'llms_forms_get_free_enroll_form_fields', $fields, $plan );
}
/**
* Retrieve the HTML of form fields used for the "free enrollment" form
*
* @since 5.0.0
*
* @see LLMS_Forms::get_free_enroll_form_fields()
*
* @param LLMS_Access_Plan $plan Access plan being used for enrollment.
* @return string
*/
public function get_free_enroll_form_html( $plan ) {
$html = '';
foreach ( $this->get_free_enroll_form_fields( $plan ) as $field ) {
$html .= llms_form_field( $field, false );
}
return $html;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.0.0 | Retrieve and use the free checkout redirect URL as not encoded. |
| 5.9.0 | Fix php 8.1 deprecation warnings when get_form_fields() returns false. |
| 5.1.0 | Specifiy to pass the new 3rd param to the llms_forms_block_to_field_settings filter callback. |
| 5.0.0 | Introduced. |