WordPress redirect https to http without SSL certificate

If your website has an invalid SSL certificate for your site (perhaps your shared hosting company has a wildcard certificate), most browsers will show a warning about the validity of the certiticate.

However, Google could still index your site using https: URLs, as it assumes you have a valid SSL certificate.

The problem is, if people click the links from Google, they get the browser warning.

Changes to your htaccess file wont work as.

Here is a php snippet you can drop into your theme functions.php. It redirects at the PHP level.

// Avoid SSL on Google
add_action( 'template_redirect', 'bhww_ssl_template_redirect', 1 );
function bhww_ssl_template_redirect() {
  $https = ( $_SERVER['HTTP_X_HTTPS'] == 'On' );
  if ( $https ) {
    if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
      wp_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ), 301 );
      exit();
    } else {
      wp_redirect( ‘http://’ . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’], 301 );
      exit();
    }
  }
}

Assign a Tag to a Contact in Infusionsoft using Affiliates Pro

If you’re using Affiliates Pro, and Infusionsoft, you might want to tag the Infusionsoft contact for an affiliate, once they have signed up.

Here’s a handy function to do that.

Important: You need to installed the Infusionsoft SDK plugin first (or add the SDK to your theme yourself).

// Affiliate added
add_action( 'affiliates_added_affiliate', 'my_affiliates_added_affiliate' );
function my_affiliates_added_affiliate( $affiliate_id ) {

  global $wpdb;

  $groupid = 1601; // Set your tag id from Infusionsoft

  // Get the AffiliatesPro details from WP
  $affiliate = $wpdb->get_results("SELECT * FROM wp_aff_affiliates WHERE affiliate_id = $affiliate_id");
  $affiliate = current($affiliate);

  // Get the contact details from InfusionSoft
  $contacts = Infusionsoft_DataService::query(new Infusionsoft_Contact(), array('Email' =>   $affiliate->email));
  $found = array_shift($contacts);

  $contactID = $found->Id;

  // Got it

  // Add the tag in Infusionsoft
  Infusionsoft_ContactService::addToGroup($contactID, $groupid);

}