Skip to content

Instantly share code, notes, and snippets.

@tott
Created November 8, 2013 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tott/7378575 to your computer and use it in GitHub Desktop.
Save tott/7378575 to your computer and use it in GitHub Desktop.
redirect pages with gravity forms to https
// 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();
}
}
}
@ajay786singh
Copy link

Thanks That help a lot to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment