Tagged: x
-
AuthorPosts
-
May 24, 2016 at 8:01 pm #1008243
mevans1576ParticipantHello,
I am trying to create a function that will force the use of https for specific pages in my site. I understand how to create the function. The issue I am having is figuring out what action hook to use to call my function.
The function I want to create is something like this:
function force_ssl()
{
// Specify ID of page to be viewed on SSL connection
if (is_page(149) && !is_ssl () )
{
header(‘HTTP/1.1 301 Moved Permanently’);
header(“Location: https://” . $_SERVER[“SERVER_NAME”] . $_SERVER[“REQUEST_URI”]);
exit();
}
// All other pages must not be https
else if (!is_page(149) && is_ssl() )
{
header(‘Location: http://’ . $_SERVER[‘SERVER_NAME’].$_SERVER[‘REQUEST_URI’]);
exit();
}
}I would then call it using something like this: add_action(‘I need a hook for this part’, ‘force_ssl’);
What I need help with is determining what action to hook onto. Is there an existing template redirect action or ssl action in the theme that I can use? Hopefully I’ve explained what I’m looking for.
Thanks,
Mike
May 24, 2016 at 8:56 pm #1008334
mevans1576ParticipantThis reply has been marked as private.May 24, 2016 at 9:05 pm #1008343
mevans1576ParticipantOk sorry for yet another post but I figured it out. It was an issue with my child theme. Apparently you have to activate the child theme before any functions you write will work. Doh!
May 24, 2016 at 11:34 pm #1008483
RupokMemberGlad that you figured it out already. Feel free to let us know if you face any other issue. We’ll be happy to assist you.
Thanks for using X.
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1008243 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
