• Resolved lukiano880

    (@lukiano880)


    Hello.
    After submitting, I want to display a message with a link to download a file, but the “download” attribute is removed from the “a” tag.
    I am using this code, but do not works:

    add_filter( 'forminator_change_form_allowed_html', function( $allowed_html ){	
    	$allowed_html = array(	
    			'a' => array(
    						'download' => true,
    					),		
    	);
    	return $allowed_html;
    } );
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @lukiano880

    Hope you’re doing well today! I am sorry to hear about the issue you’re facing.

    I was able to test the snippet and the behaviour of the download attribute on my test site and noticed that the download attribute is indeed stripped off from the tag when added to the inline message.

    I am checking further about this with our developer team to gain some more insights from them about the issue. We will update you on this topic as soon as we receive further information.

    Kind Regards,
    Saurabh

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @lukiano880

    Hope you’re doing well today!

    Small note, it seems like some part of my reply got anchored due to some glitch I believe, request you to please ignore the anchor.

    Just following up about the issue, I have an update from our developer team regarding the issue. The filter you’re using in the Snippet that you’ve shared does not exists on the plugin’s code. However, you can remove the existing code and replace that with the below snippet.

    <?php
    add_filter( 'forminator_replace_form_data', 'wpmudev_download_file_message_link', 10, 3 );
    function wpmudev_download_file_message_link( $content, $data, $original_content ) {
        if ( 30 !== intval( $data['form_id'] ) ) { // Please change the form ID.
            return $content;
        }
    
        if ( strpos( $content, '{download_link}' ) !== false ) {
            $content = str_replace( '{download_link}', '<a href="your_file_path" download>Download</a>', $content );
        }
    
        return $content;
    }

    Please follow the instructions below to add the snippet:
    You can add the above snippet as a mu-plugin, for this, you can navigate to the /wp-content/mu-plugins/ directory and create a new PHP file. For example, forminator-download-message.php and paste the above snippet to the file and proceed with the below steps.

    Update Form ID:
    On the line?
    if ( 30 !== intval( $data['form_id'] ) ) { // Please change the form ID.
    Please replace the 30 with your Form ID, a form ID is the number that you see on the form shortcode. For example, if [forminator_form id=”30″] is the shortcode, 30 will be the form ID.

    Update the path of the file that you want the users to be able to download:
    On the line
    $content = str_replace( '{download_link}', '<a href="your_file_path" download>Download</a>', $content );

    You will need to replace the “your_file_path” with the actual path of the file that you want the users to download. For example: “https://yourwebsite.com/wp-content/uploads/2024/05/example-file.pdf&#8221;

    Add Macro to the submission message:
    Lastly, you will need to add {download_link} macro to the submission message which will render the “Download” link (Ref: https://monosnap.com/file/VEzNrfApkTyvDg99170OmksRAm9GEr)

    Hope this helps. Please let us know in case you have any questions/queries about this issue.

    Kind Regards,
    Saurabh

    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hello @lukiano880,

    I hope the latest snippet provided above helped resolving the issue.

    We’ll be marking this thread as resolved for now. Please feel free to reply if you need our further assistance, or still have any questions.

    Best Regards,
    Dmytro

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Attribute “download” is removed’ is closed to new replies.