LLMS_Form_Handler::insert( string $action, array $posted_data, array[] $fields )

Insert user data into the database.

Parameters Parameters


(string) (Required) Type of insert action. Either "registration" for a new user or "update" for an existing one.


(array) (Required) User-submitted form data.


(array[]) (Required) List of LifterLMS Form fields for the form.

Top ↑

Return Return

(WP_Error|int) Error on failure or WP_User ID on success.

Top ↑

Source Source

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

	protected function insert( $action, $posted_data, $fields ) {

		$func     = 'registration' === $action ? 'wp_insert_user' : 'wp_update_user';
		$prepared = $this->prepare_data_for_insert( $posted_data, $fields, $action );

		$user_id = $func( $prepared['users'] );
		if ( is_wp_error( $user_id ) ) {
			return $user_id;

		foreach ( $prepared['usermeta'] as $key => $val ) {
			update_user_meta( $user_id, $key, $val );

		return $user_id;


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.