Created
November 8, 2013 22:18
-
-
Save tott/7378575 to your computer and use it in GitHub Desktop.
redirect pages with gravity forms to https
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// redirect all gravity forms to ssl | |
add_action( 'template_redirect', 'sav_force_ssl_for_contact_forms', 1 ); | |
function sav_force_ssl_for_contact_forms() { | |
if ( is_page() && ! is_ssl() ) { | |
global $post; | |
if ( ! preg_match( '#\[gravityform#msiU', $post->post_content ) ) | |
return; | |
if ( preg_match( '#^http://#', $_SERVER['REQUEST_URI'] ) ) { | |
wp_redirect( preg_replace( '#^http://#', 'https://', $_SERVER['REQUEST_URI'] ), 301 ); | |
exit(); | |
} else { | |
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 ); | |
exit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks That help a lot to me.