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

LifterLMS LifterLMS

Code Reference

  • Home
  • 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

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

Description #Description


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 ↑

Changelog #Changelog

Changelog
Version Description
3.7.0 Introduced.

Top ↑

Related #Related

Top ↑

Uses #Uses

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

Verify nonce with additional checks to confirm request method Skips verification if the nonce is not set Useful for checking nonce for various LifterLMS forms which check for the form submission on init actions

includes/llms.functions.core.php: llms_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()

Perform validations according to $screen and updates the 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 EG: ‘checkout’, ‘memberships’, ‘myaccount’, ‘courses’ etc.

Show 1 more use Hide more uses

Top ↑

User Contributed Notes #User Contributed Notes

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





Permalink:
© 2014 - 2019 LifterLMS · Privacy Policy · Terms and Conditions