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

Form fields submission.


Parameters Parameters

$posted_data

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

$location

(string) (Required) Form location ID.

$fields

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

$action

(string) (Required) User action to perform.


Top ↑

Return Return

(int|WP_Error) WP_User ID on success, error object on failure.


Top ↑

Source Source

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

361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
public function submit_fields( $posted_data, $location, $fields, $action ) {
 
    $validate = $this->validate_fields( $posted_data, $location, $fields, $action );
    if ( is_wp_error( $validate ) ) {
        return $validate;
    }
 
    // Sanitize.
    $posted_data = $this->validator->sanitize_fields( $posted_data, $fields );
 
    $user_id = $this->insert( $action, $posted_data, $fields );
    if ( is_wp_error( $user_id ) ) {
        return $this->submit_error( $user_id, $posted_data, $action );
    }
 
    if ( 'registration' === $action ) {
 
        /**
         * Deprecated user creation hook.
         *
         * @since Unknown.
         * @deprecated 5.0.0
         *
         * @param int    $user_id     WP_User ID of the newly created user.
         * @param array  $posted_data Array of user-submitted data.
         * @param string $location    Form location.
         */
        do_action_deprecated(
            'lifterlms_created_person',
            array( $user_id, $posted_data, $location ),
            '5.0.0',
            'lifterlms_user_registered'
        );
 
        /**
         * Fire an action after a user has been registered.
         *
         * @since 3.0.0
         * @since 5.0.0 Moved from `LLMS_Person_Handler::register()`.
         *
         * @param int    $user_id     WP_User ID of the user.
         * @param array  $posted_data Array of user submitted data.
         * @param string $location    Form location.
         */
        do_action( 'lifterlms_user_registered', $user_id, $posted_data, $location );
 
    } elseif ( 'update' === $action ) {
 
        /**
         * Fire an action after a user has been updated.
         *
         * @since 3.0.0
         * @since 5.0.0 Moved from `LLMS_Person_Handler::update()`.
         *
         * @param int    $user_id     WP_User ID of the user.
         * @param array  $posted_data Array of user submitted data.
         * @param string $location    Form location.
         */
        do_action( 'lifterlms_user_updated', $user_id, $posted_data, $location );
 
    }
 
    return $user_id;
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Moved validation logic to the validate_fields() method.
6.0.0 Notify developers of the deprecated lifterlms_created_person action hook.
5.4.1 Sanitize filed only after validation. See <a href="https://github.com/gocodebox/lifterlms/issues/1829">https://github.com/gocodebox/lifterlms/issues/1829</a>.
5.1.0 Added "lifterlms*user*${action}_required_data" filter, to filter the required fields validity of the form submission.
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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