LLMS_Forms_Data::save_username_locations( int $post_id, WP_Post $post )

When saving a form store a form reference in the options table

Description Description

This will be used to LLMS_Forms::are_usernames_enabled() to determine if the site allows login via usernames.

Callback function for save_post_llms_forms and delete_post hooks.

Top ↑

Parameters Parameters


(int) (Required) ID of the form being saved.


(WP_Post) (Required) Form post object.

Top ↑

Return Return

(int[]) Returns an array of WP_Post IDs representing all the forms where the username block existss.

Top ↑

Source Source

File: includes/forms/class-llms-forms-data.php

	public function save_username_locations( $post_id, $post ) {

		// Load existing locations.
		$locations = get_option( 'llms_forms_username_locations', array() );

		$post_id            = absint( $post_id );
		$blocks             = $this->forms->parse_blocks( $post->post_content );
		$has_username_block = $this->has_username_block( $blocks );

		// Add or remove the location depending on the presence of the block.
		if ( $has_username_block ) {
			$locations[] = $post_id;
		} else {
			$locations = array_diff( $locations, array( $post_id ) );

		$locations = array_unique( $locations );

		// Store it.
		update_option( 'llms_forms_username_locations', $locations );

		return $locations;


Top ↑

Changelog Changelog

Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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