LLMS_Admin_User_Custom_Fields::save( mixed $user )

Save custom field data for a user


Description Description


Parameters Parameters

$user

(mixed) (Required) WP_User or WP_User ID


Top ↑

Return Return

(void)


Top ↑

Source Source

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

	public function save( $user ) {

		if ( is_numeric( $user ) ) {
			$user = new WP_User( $user );
			// an object that's not a WP_User gets passed in during updates
		} elseif ( isset( $user->ID ) ) {
			$user = new WP_User( $user->ID );
		}

		// saves custom fields
		foreach ( $this->fields as $field => $data ) {

			update_user_meta( $user->ID, $field, sanitize_text_field( apply_filters( 'lifterlms_save_custom_user_field_' . $field, $_POST[ $field ], $user, $field ) ) );

		}

		// save instructor assistant's parent instructor
		if ( in_array( 'instructors_assistant', $user->roles ) && ! empty( $_POST['llms_parent_instructors'] ) ) {

			$instructor = llms_get_instructor( $user );
			$instructor->add_parent( $_POST['llms_parent_instructors'] );

		}

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.13.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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