Skip to content

Instantly share code, notes, and snippets.

@adczk
Created April 18, 2022 12:11
Show Gist options
  • Select an option

  • Save adczk/18443734ebcda8165888130c4298d9d9 to your computer and use it in GitHub Desktop.

Select an option

Save adczk/18443734ebcda8165888130c4298d9d9 to your computer and use it in GitHub Desktop.
Forminator - prevent field cut, copy, paste
<?php
/*************************
*
* Forminator - prevent cut/copy/paste in fields
*
* adjust fields CSS IDs in code if needed
*
* by adamcz/WPMU DEV
*
* tested with Forminato 1.15.12
*
* use as MU plugin
*
**************************/
add_action( 'wp_footer', 'my_form_prevent_paste', 99 );
function my_form_prevent_paste() {
ob_start();
?>
<script>
( function( $ ) {
$( document ).ready( function() {
$( '#forminator-field-email-1' ).on( 'cut copy paste', function( e ) {
e.preventDefault();
});
$( '#forminator-field-email-2' ).on( 'cut copy paste', function( e ) {
e.preventDefault();
});
});
} ( jQuery ) );
</script>
<?php
$scripts = ob_get_clean();
echo $scripts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment