Skip to content

Instantly share code, notes, and snippets.

@milossh
milossh / buddypress-disable-auto-password.php
Created January 30, 2021 21:32
Disable auto password generation on registration page - BuddyPress
<?php
// Disable auto password generation on register page
add_action( 'bp_before_register_page', 'mtc_hlr_register_disable_random_password' );
function mtc_hlr_register_disable_random_password() {
add_filter( 'random_password', '__return_empty_string' );
}
@milossh
milossh / wp-contact-form-7-preven-multiple-submissions.html
Created January 8, 2021 01:36
WP Contact Form 7 - Prevent double form submission by clicking submit button more than once( again )
<script>
jQuery(document).on('click', '.wpcf7-submit', function(e){
if( jQuery('.ajax-loader').hasClass( 'is-active' ) ) {
e.preventDefault();
return false;
}
});
</script>
@milossh
milossh / wordpress-is-blog.php
Created January 5, 2021 07:47
Function to determine whether current page is part of Blog system in WordPress - Returns boolean
<?php
// Is the current page a part of Blog system in WordPress - Returns boolean
function mtc_is_blog () {
return ( is_archive() || is_author() || is_category() || is_single() || is_tag() ) && 'post' == get_post_type();
}
@milossh
milossh / wp-remove-gravity-from-styles-scripts.php
Created January 5, 2021 07:41
WordPress - Remove Gravity Forms styles and scripts from home page
<?php
/* Remove gravity forms from home page */
add_action( 'wp_enqueue_scripts', 'mtc_dequeue_gravity_frontpage', 9999 );
add_action( 'wp_head', 'mtc_dequeue_gravity_frontpage', 9999 );
function mtc_dequeue_gravity_frontpage() {
// Leave gravity form styles and scripts included if we're not on home page