Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Matt Harrison

    (@matt-h-1)

    Looking at that example, that should work perfectly fine with this plugin.

    This plugin could block emails that you add to the blacklist and then your code could be the secondary validation pass on ones that get through.

    Thread Starter kh7654

    (@kh7654)

    Thanks for the speedy and helpful reply response, Matt. I’ll give it a go and feed back.

    Thread Starter kh7654

    (@kh7654)

    Just confirming we’ve now installed and tested partnering an external API for email verification running alongside the Gravity Forms Email Blacklist plugin, and they work together nicely. So you can use the plugin to catch addresses from your local blacklist and then hand over to the external API to ensure the address is otherwise valid.

    We are using Reeoon.com. This is the code we added in functions.php (adapted from the generic example supplied in Gravity Forms documentation):

    /* GF: email validation - external api */
    add_filter( 'gform_field_validation', function ( $result, $value, $form, $field ) {
        if ( $field->get_input_type() === 'email' && $result['is_valid'] ) {
            $request_url = add_query_arg(
                array(
                    'email'  => $value,
                    'key' => 'yourapikey',
                ),
                'https://emailverifier.reoon.com/api/v1/verify'
            );
    
            $response       = wp_remote_get( $request_url );
            $response_json  = wp_remote_retrieve_body( $response );
            $response_array = json_decode( $response_json, 1 );
            if ( rgar( $response_array, 'status' ) !== 'valid' ) {
                $result['is_valid'] = false;
                $result['message']  = 'Email is not valid';
            }
        }
      
        return $result;
    }, 10, 4 );
    • This reply was modified 2 years, 2 months ago by kh7654.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Play nice with external api?’ is closed to new replies.