PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.1
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.1
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / form-builder / form-builder-hooks.php

form-builder-hooks.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.1, at form-builder/form-builder-hooks.php

54 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcode default-form ID resolution, and an unconditional
4 * `wppb_change_form_fields` registration so per-form ordering works even when
5 * the classic module gate is 'hide'. add_filter() de-duplicates if the bundled
6 * conditional registration also runs.
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) exit;
10
11 // Safe before multiple-forms.php is included: add_filter() does not resolve the
12 // callback until `wppb_change_form_fields` fires.
13 add_filter( 'wppb_change_form_fields', 'wppb_multiple_forms_change_fields', 10, 2 );
14
15 /**
16 * Force Multiple Registration / Edit Profile Forms module gates to 'show' on
17 * every read so classic-mode WCK admin UI loads. Read-only — do not write back
18 * (would persist the filtered value into a site option the user never set).
19 */
20 add_filter( 'option_wppb_module_settings', 'wppb_fb_force_multiple_forms_modules_active' );
21 // Absent option rows fire `default_option_*` instead of `option_*`.
22 add_filter( 'default_option_wppb_module_settings', 'wppb_fb_force_multiple_forms_modules_active' );
23 function wppb_fb_force_multiple_forms_modules_active( $settings ) {
24 if ( ! is_array( $settings ) ) $settings = array();
25 $settings['wppb_multipleRegistrationForms'] = 'show';
26 $settings['wppb_multipleEditProfileForms'] = 'show';
27 return $settings;
28 }
29
30 add_filter( 'wppb_form_args_after_init', 'wppb_fb_resolve_default_form_id', 10 );
31
32 /**
33 * Bind a bare shortcode to the configured default form when no ID was passed.
34 *
35 * @param array $args Form render args from the `wppb_form_args_after_init` filter.
36 * @return array
37 */
38 function wppb_fb_resolve_default_form_id( $args ) {
39 if ( ! empty( $args['ID'] ) ) return $args;
40
41 // Type is `$args['form_type']`, not a `context` key.
42 $form_type = ( isset( $args['form_type'] ) && $args['form_type'] === 'edit_profile' )
43 ? 'edit_profile'
44 : 'register';
45
46 $defaults = get_option( 'wppb_default_form_ids', array() );
47
48 if ( ! empty( $defaults[ $form_type ] ) ) {
49 $args['ID'] = $defaults[ $form_type ];
50 }
51
52 return $args;
53 }
54