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.
Parameters Parameters
- $post_id
-
(int) (Required) ID of the form being saved.
- $post
-
(WP_Post) (Required) Form post object.
Return Return
(int[]) Returns an array of WP_Post IDs representing all the forms where the username block existss.
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; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |