Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1008243
    mevans1576
    Participant

    Hello,

    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

    #1008334
    mevans1576
    Participant
    This reply has been marked as private.
    #1008343
    mevans1576
    Participant

    Ok 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!

    #1008483
    Rupok
    Member

    Glad 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!

  • <script> jQuery(function($){ $("#no-reply-1008243 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>