Email invoices linking to HTTP not HPPTS

This topic contains 11 replies, has 5 voices, and was last updated by  Kiran 6 years, 5 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #818

    Dan Lee
    Free User
    Post count: 28

    When an email is sent saying an invoice can be viewed, the URL is being sent from a http and not an https URL.

    I only have my payment systems and invoice with HTTPS and not the whole side, is there a way to add HTTPS to your invoicing system ?

    SORRY POSTED THIS IN GENERAL DISCUSSION BY MISTAKE

    #820

    Dan Lee
    Free User
    Post count: 28

    Or could we have a “FORCE HTTPS” option for the plug in like some of the other invoice plug-ins around.

    #821

    Alex Rollin
    Moderator
    Post count: 27815

    Hello!

    Invoicing uses your site URL settings. Your’s is a special case, and a customization that would go beyond support. This is a very general WordPress function and you could probably find a solution online.

    I have never encountered a setup like that before. Is there a reason you have it setup that way?

    #823

    Dan Lee
    Free User
    Post count: 28

    Its more common than you think, yes the reason is we get better performance when a client is in their dedicated client zone which they log into, but marking the leap into https and then out again when they return to the client zone works better.

    Plus when delivering images online to clients we dont have to worry about mixed content. This solution is much better when delivering unsecured content that doesnt need to be secured. Plus we have an API that connects to clients databases which works freely over HTTP

    So we have it set up this way.

    Its not a support issue but it needs to be added. Pretty much every invoicing tool I’ve used else where has the “Force HTTPS” option in its general settings, so I dont buy the “its a unique setup”

    #824

    Paolo
    Site Admin
    Post count: 31206

    Hi Dan,

    the developers will look into it and let you know how this can be solved, possibly with a code snippet or by adding a new setting if the 1st option isn’t possible.

    Thanks

    #827

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    The system uses the wp settings, you can use the below snippet to redirect any page to its https url by the page id, might also be handy for you for other things:

    
    
    add_action('wp','_my_custom_ssl_redirect');
    function _my_custom_ssl_redirect(){
        global $post,$wp;
    
        $page_ids = array(2,123,321,456); // array of page ids we want to force to ssl.
    
        if( is_page() && isset($post->ID) && in_array($post->ID,$page_ids) ){ 
            wp_safe_redirect( add_query_arg( $_SERVER['QUERY_STRING'], '',trailingslashit(home_url( $wp->request, "https" ), 301 )) );
            exit;
        }
    }

    Also FYI if your server is running http2 and is all https it will likely be faster than http.

    Thanks,

    Stiofan

    #830

    Dan Lee
    Free User
    Post count: 28

    How does that “snippet” redirect the email URL out to https as the page ids change everytime or am I missing something ? The email invoice comes with a token at the end of the URL string too.

    Yes I know it uses the wp settings but I dont want it to, hence having an in app toggle that doesnt require extra code is a benefit.

    As for your comment about it being faster, yes it should but in our use case it doesnt.

    #833

    Kiran
    Moderator
    Post count: 7069

    Hi Dan,

    Above snippet will work to force HTTPS for particular pages or posts. Use following snippet to force HTTPS for all the invoices.

    
    
    function _wpi_custom_ssl_redirect(){
        global $post, $wp;
    
        if ( ! empty( $post->ID ) && ! empty( $post->post_type ) && $post->post_type == 'wpi_invoice' && is_singular() && is_single() ) {
            if ( strpos( wpinv_get_current_page_url(), 'https://' ) !== 0 ) {
                wp_safe_redirect( add_query_arg( $_SERVER['QUERY_STRING'], '', trailingslashit( home_url( $wp->request, "https" ), 301 ) ) );
                exit;
            }
        }
    }
    add_action( 'wp', '_wpi_custom_ssl_redirect' );

    Thanks,
    Kiran

    #834

    Dan Lee
    Free User
    Post count: 28

    Do I need to modify that in anyway to work on my site ?

    #842

    Kiran
    Moderator
    Post count: 7069

    If you want to force all the invoices to use HTTPS, then remove previous snippet provided in reply #827 use snippet as it is provided in reply #834.

    Kiran

    #843

    Dan Lee
    Free User
    Post count: 28

    Got it that works by the looks of it.

    Thanks you Kiran, appreciated.

    #849

    Kiran
    Moderator
    Post count: 7069

    Thanks for letting us know 🙂

Viewing 12 posts - 1 through 12 (of 12 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket