LLMS_Admin_User_Custom_Fields::save( WP_User|int|obj $user )
Save custom field data for a user
Parameters Parameters
- $user
-
(WP_User|int|obj) (Required) User object or id.
Return Return
(void)
Source Source
File: includes/admin/class.llms.admin.user.custom.fields.php
public function save( $user ) { if ( is_numeric( $user ) ) { // Numeric ID is passed in during creations. $user = new WP_User( $user ); $action = 'create'; } elseif ( isset( $user->ID ) ) { // An object that's not a WP_User gets passed in during updates. $user = new WP_User( $user->ID ); $action = 'update'; } // Saves custom fields. foreach ( $this->fields as $field => $data ) { $value = apply_filters( 'lifterlms_save_custom_user_field_' . $field, llms_filter_input_sanitize_string( INPUT_POST, $field ), $user, $field ); update_user_meta( $user->ID, $field, $value ); } // Save instructor assistant's parent instructor. if ( in_array( 'instructors_assistant', $user->roles, true ) && ! empty( $_POST['llms_parent_instructors'] ) ) { // phpcs:disable WordPress.Security.NonceVerification.Missing $instructor = llms_get_instructor( $user ); $instructor->add_parent( llms_filter_input( INPUT_POST, 'llms_parent_instructors', FILTER_SANITIZE_NUMBER_INT, FILTER_REQUIRE_ARRAY ) ); } // Save personal options. if ( user_can( $user, 'edit_courses' ) && 'create' !== $action ) { $autosave = empty( $_POST['llms_builder_autosave'] ) ? 'no' : 'yes'; update_user_meta( $user->ID, 'llms_builder_autosave', $autosave ); } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.9.0 | Stop using deprecated FILTER_SANITIZE_STRING . |
4.14.0 | Save builder autosave personal options. |
3.37.15 | Use strict comparisons. |
3.35.0 | Sanitize input data. |
3.13.0 | Introduced. |