LLMS_Admin_User_Custom_Fields::add_errors( obj $errors, bool $update, WP_User $user )

Validate custom fields


Description Description

During updates will save data, creation is saved during a different action.


Top ↑

Parameters Parameters

$errors

(obj) (Required) Instance of WP_Error, passed by reference.

$update

(bool) (Required) true if updating a profile, false if a new user.

$user

(WP_User) (Required) Instance of WP_User for the user being updated.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/admin/class.llms.admin.user.custom.fields.php

	public function add_errors( &$errors, $update, $user ) {

		$this->get_fields();

		$error = $this->validate_fields( $user );

		if ( $error ) {

			$errors->add( '', $error, '' );

			if ( $update ) {
				$this->save( $user );
			}

			// Don't save.
			remove_action( 'edit_user_created_user', array( $this, 'save' ) );

			return;

		}

		// If updating, save here since there's no other save specific admin action (that I could find).
		if ( $update ) {
			$this->save( $user );
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.37.15 Correctly pass $user to $this->save().
3.13.0 Unknown.
2.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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