Forum Replies Created

Viewing 15 replies - 1 through 15 (of 19 total)
  • Thread Starter danidada

    (@danidada)

    Hello, thanks for your reply Amin and sorry for my delay.
    I understand your mention about the custom coding being out of scope, but let me just correct one thing in your reply: you wrote “If only the modified field is injected using array_replace(), the notification conditions will not have the complete context of the submission” but in here

    Forminator_Front_Action::$prepared_data = array_replace( Forminator_Front_Action::$prepared_data, $submitted_data );

    $submitted_data is extracted from the entry

    private function data_from_enty( $entry ) {
    $post_data = array();
    foreach ( $entry->meta_data as $key => $meta ) {

    if ( ! isset( $meta['value'] ) ) {
    continue;
    }
    $post_data[ $key ] = $meta['value'];
    }
    return $post_data;
    }

    so it contains all data, not only the edited one.

    The only way I’ve found to workaround the problem is to manually remove the conditions in the notifications ( in $custom_form->notifications before passing it as the first parameter of $forminator_mail_sender->process_mail ) but I don’t really like it (although it works) so if I need to pass the context as you said with another call like you wrote, could you enlighten me? Because I didn’t find any of it in the code.

    Thanks again

    Thread Starter danidada

    (@danidada)

    Just to get you an update on the code I’m testing. Now it reflects new value on email notification content BUT it doesn’t fire if there is a condition based on the updated field value.

    //the update
    Forminator_API::update_form_entry( $form_id, $entry_id, array( array('name'=>'hidden-3', 'value'=>"si") ) );

                        $error = '';

                        if ( isset( $entry_id ) ) {

                            $get_data_from_entry = $this->data_from_enty($entry);

                            $submitted_data = Forminator_Core::sanitize_array( $get_data_from_entry );

                            // Send email.

                            $custom_form = Forminator_Form_Model::model()->load( $form_id );

                            if ( ! is_object( $custom_form ) ) {

                                $error .= json_encode(

                                    array(

                                        'message' => apply_filters(

                                            'forminator_draft_invalid_form_id',

                                            esc_html__( 'Invalid form ID.', 'forminator' ),

                                            $form_id

                                        ),

                                    )

                                );

                            }

                            $forminator_mail_sender       = new Forminator_CForm_Front_Mail();

                            $draft_entry                  = new Forminator_Form_Entry_Model( $entry_id );

                            // just to check var_dump($draft_entry);

                            Forminator_Front_Action::$prepared_data = array_replace( Forminator_Front_Action::$prepared_data, $submitted_data );

                            $mail_sent                    = $forminator_mail_sender->process_mail( $custom_form, $draft_entry );


                        }

    Can you please tell me what I am missing? Just ANY condition stop the notification from being sent, also for fields that wasn’t updated.

    • This reply was modified 2 weeks, 5 days ago by danidada.
    • This reply was modified 2 weeks, 5 days ago by danidada.
    Thread Starter danidada

    (@danidada)

    Hello Patrick,

    I am using the class and function you mentioned but the data sent in the notification is the “old” data, not the updated entry data. I have used the same code as in the plugin.

                        // this one is the code updating the field value 
    Forminator_API::update_form_entry( $form_id, $entry_id, array( array('name'=>'hidden-3', 'value'=>"si") ) );

                        $error = '';

                        if ( isset( $entry_id ) ) {

                            $forminator_mail_sender = new Forminator_CForm_Front_Mail();

                            $entry                  = new Forminator_Form_Entry_Model( $entry_id );


                            if ( empty( $entry->form_id ) || ! empty( $entry->draft_id ) ) {

                                $error = esc_html__( 'Entry ID was not found.', 'forminator' );

                            }

                            $module_id = $entry->form_id;

                            Forminator_Front_Action::$module_id     = $module_id;

                            Forminator_Front_Action::$module_object = Forminator_Base_Form_Model::get_model( $module_id );

                            // Emulate Forminator_Front_Action::$prepared_data.

                            Forminator_Front_Action::$prepared_data = recreate_prepared_data( Forminator_Front_Action::$module_object, $entry );

                            // Emulate Forminator_Front_Action::$hidden_fields.

                            if ( ! Forminator_Front_Action::$module_object ) {

                                $error = esc_html__( 'Error: Module object is corrupted!', 'forminator' ) ;

                            }

                            Forminator_Front_Action::$module_settings = method_exists( Forminator_Front_Action::$module_object, 'get_form_settings' )

                            ? Forminator_Front_Action::$module_object->get_form_settings() : Forminator_Front_Action::$module_object->settings;

                            Forminator_CForm_Front_Action::check_fields_visibility();

                            $module_object = Forminator_Base_Form_Model::get_model( $module_id );
    // printed data is the updated one
                            var_dump($entry);
    //data sent by mail is the old one
                            $forminator_mail_sender->process_mail( $module_object, $entry );
    Thread Starter danidada

    (@danidada)

    Thank you for the fast reply!

    I added the code and set it on “Copy once” now it is in the translation as expected. Perfect!

    It’s enough for what I need. Thank you.

    Thread Starter danidada

    (@danidada)

    Thanks, please update this thread when it will be fixed and released.

    Thread Starter danidada

    (@danidada)

    thank you for the fast reply.

    Meanwhile is possible to use a filter to disable the functionality on specific blocks? It’s just to avoid the message error.

    Thread Starter danidada

    (@danidada)

    I’m just adding a detail: I could restrict the block to the custom post type, but the issue was to allow its use inside the fse template for the custom post type because I’m registering it through “acf_register_block_type” and using the parameter “post_types” doesn’t let me have it available inside the template editor.

    Thread Starter danidada

    (@danidada)

    Yes, you were right and I’ve also found out what is causing the missing “duplicate” option but I can’t understand why it’s happening….

    The culprit is this filter:

    add_filter( 'allowed_block_types_all', function( $allowed_block_types, $block_editor_context ) {
    if ( isset( $block_editor_context->post ) && $block_editor_context->post->post_type !== 'prodotto_ag' ) {
    $blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
    // Blocks to remove.
    $disallowed_blocks = [
    'acf/prod-price',
    ];
    foreach ( $disallowed_blocks as $block ) {
    unset( $blocks[ $block ] );
    }
    return array_keys( $blocks );
    }
    }, 10, 2 );

    And it’s been added to prevent the use of a custom block (acf/prod-price) on other post types (rather that “prodotto_ag”).

    Any hint?

    Thread Starter danidada

    (@danidada)

    Hello! Yes there is not option on my editor:

    It’s a custom FSE theme and these are the plugins installed:

    Thread Starter danidada

    (@danidada)

    Thanks, I think it’s a feature a user wouldn’t care for, but for a developer like me who designs a custom theme with customized styling letting who’ll manage the website be able to select only the “brand icons” would be a plus. But, anyway, I like to use your plugin because it’s light, doesn’t add too much (like templates, patterns…) and has some really nice features so… thumps up! Also, I appreciate the fast and full support.

    Thread Starter danidada

    (@danidada)

    I found a workaround that fix the problem:

    enabling the delay initialization and forcing visual mode only it loads it as code and on click inside the area display it properly with editing fully working.

    Sorry to have open this as a conflict of Premium Blocks plugin when it was not the culprit because it’s a wp bug.

    ps. can I ask something that’s not related to this issue? For the Icon Block can the standard icons be replaced with a filter to load only custom icons?

    • This reply was modified 8 months ago by danidada.
    Thread Starter danidada

    (@danidada)

    Hello again,

    thanks for the update. I’m on Firefox and it works deactivating Premium Blocks.
    I checked the issue you have linked and from what users says could be related to a delay (https://core.trac.wordpress.org/ticket/62450#comment:6) maybe just due to the resources loaded by the plugin and not a specific conflict.

    And from what I read I could try to rollback wp version at 6.6.2 but before doing that I’ll wait if you or the guys on the issue thread reply.

    Thread Starter danidada

    (@danidada)

    Sure!

    I have added unuseful details probably cause I think it’s not related to the theme but it’s between the SFC (https://it.wordpress.org/plugins/secure-custom-fields/) plugin, when on a page there is a field type Editor WYSIWYG (attached photo) and the plugin Premium Blocks for Gutenberg is active (without placing any blocks and enable/disable settings doesn’t make any difference) than in the page editor that field type is not editable in Visual mode but only on Text mode. If you edit it on Text mode and than switch back to Visual mode it’s white empty and the console shows that error.

    Attached screenshots, hope this helps.

    Thread Starter danidada

    (@danidada)

    thank you!

    Thread Starter danidada

    (@danidada)

    Here, i change the sensitive data:

    https://pastebin.com/BZ15JkgH

    Here two screenshots: https://ibb.co/k089k6P, https://ibb.co/T4xLXd2
    now the form shared on pastebin it’s set as “none” for expiration because it wasn’t updating the date, as you can see in the next screenshot the message has 23 as date but the datepicker is 20 (the old date)

    • This reply was modified 1 year, 7 months ago by danidada.
Viewing 15 replies - 1 through 15 (of 19 total)