• LifterLMS
  • Knowledge Base
  • Academy
  • Blog
  • Podcast
  • Contributors
  • My Account

LifterLMS LifterLMS

  • Code Reference
  • REST API
  • LLMS-CLI

Code Reference

Skip to content
Filter by type:
Search
Browse: Home / Code Reference / Classes / LLMS_Controller_Account / LLMS_Controller_Account::update()

LLMS_Controller_Account::update()

Handle submission of user account edit form

Contents

  • Return
  • Source
  • Related
    • Uses
  • Changelog
  • User Contributed Notes

Return #Return

(void)


Top ↑

Source #Source

File: includes/forms/controllers/class.llms.controller.account.php

	public function update() {

		if ( ! llms_verify_nonce( '_llms_update_person_nonce', 'llms_update_person' ) ) {
			return;
		}

		do_action( 'llms_before_user_account_update_submit' );

		// No user logged in, can't update!
		// This shouldn't happen but let's check anyway.
		if ( ! get_current_user_id() ) {
			return llms_add_notice( __( 'Please log in and try again.', 'lifterlms' ), 'error' );
		}

		$person_id = llms_update_user( $_POST, 'account' );

		// Validation or update issues.
		if ( is_wp_error( $person_id ) ) {

			foreach ( $person_id->get_error_messages() as $msg ) {
				llms_add_notice( $msg, 'error' );
			}
			return;

		} elseif ( ! is_numeric( $person_id ) ) {

			return llms_add_notice( __( 'An unknown error occurred when attempting to create an account, please try again.', 'lifterlms' ), 'error' );

		} else {

			llms_add_notice( __( 'Your account information has been saved.', 'lifterlms' ), 'success' );

			// Handle redirect.
			llms_redirect_and_exit( apply_filters( 'lifterlms_update_account_redirect', llms_get_endpoint_url( 'edit-account', '', llms_get_page_url( 'myaccount' ) ) ) );

		}

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Related #Related

Uses #Uses

Uses
Uses Description
includes/forms/controllers/class.llms.controller.account.php: llms_before_user_account_update_submit

Form submission handler for forms on the Student Dashboard.

includes/llms.functions.core.php: llms_verify_nonce()

Verify nonce with additional checks to confirm request method

includes/functions/llms-functions-wrappers.php: llms_redirect_and_exit()

Redirect and exit

includes/functions/llms.functions.notice.php: llms_add_notice()

Stores notice in llms_notices session

includes/functions/llms.functions.person.php: llms_update_user()

Update a user.

includes/functions/llms.functions.page.php: llms_get_endpoint_url()

Retrieve the full URL to a LifterLMS endpoint.

includes/functions/llms.functions.page.php: llms_get_page_url()

Retrieve the URL for a LifterLMS Page.

Show 2 more uses Hide more uses

Top ↑

Changelog #Changelog

Changelog
Version Description
3.7.0
3.24.0 Introduced.

Top ↑

User Contributed Notes #User Contributed Notes

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

© 2014 - 2023 LifterLMS · Privacy Policy · Terms and Conditions

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.