Showing Coding

Custom Blacklist Contact Form 7


Easily set up a blacklist for those marketing lists that somehow get around Akismet. Throw the below in your functions.php file and customize the $blacklist array to filter by email address to your liking.

function contactFilterBlacklist( $result, $tag ) {

    $valid = true;
    $tag = new WPCF7_Shortcode( $tag );
    $blacklist = array(

    $yourEmail = isset( $_POST['your-email'] ) ? trim( $_POST['your-email'] ) : false;
    if ( !$yourEmail ) return $result;

    foreach ( $blacklist as $keyword ) {
        if ( strpos($yourEmail, $keyword) !== false ) $valid = false;

    if ( !$valid ) $result->invalidate( $tag, "Uh oh. Something's wrong here..." );

    return $result;

add_filter( 'wpcf7_validate_email*', 'contactFilterBlacklist', 20, 2 );

Head over to this Contact Form 7 post or their documentation to learn more.

Custom Validation

Asynchronous Javascript Loading


These posts are going to be short until I reformat all of the previous ones. With that in mind, saved a couple seconds loading time on a project I’m working on by simply loading social media javascript links asynchronously. Easy to implement and cleans the code up quite a bit!

CSS-Tricks: Thinking Async