Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jsbajada

    (@jsbajada)

    Managed to hack a way around it so I get the behaviour I want. Here is what I did (for the benefit of anyone else looking to solve the problem):

    1. WP-Invoice > Settings > Business Process > Set “Display dashboard on the … page” to an empty page called Clients, with a slug of clients

    2. WP-Invoice > Settings > Business Process > Set “Display invoices on the … page” to an empty page called Invoice, with a slug of invoice

    3. WP-Invoice > Settings > Business Process > How to Insert Invoice > Set to “Unified Page Template”

    4. WP-Invoice > Settings > Main > “Show invoices only for logged in recipients.” should be unticked (counter-intuitive, I know, but we fix that with the code below)

    5. WP-Invoice > Settings > Main > “Use Custom templates” should be ticked. The template files get copied to the /wp-content/themes/<<theme name>>/wpi folder.

    From what I can tell, everything else in the WP-Invoice > Settings page can be as you choose.

    6. In the /wp-content/themes/<<theme name>>/wpi folder, edit the client_dashboard.php file as follows:
    Replace the following code
    global $invoice, $wpi_settings;
    with

    global $post, $invoice, $wpi_settings;
    
    $domain = $_SERVER['HTTP_HOST'];
    $domain_extension = $_SERVER['REQUEST_URI'];
    $full_URL = $domain.$domain_extension;
    $is_page_clients = is_page( 'clients' );
    $is_user_logged_in = is_user_logged_in();
    $redirect_URL = "http://".$domain."/wp-login.php?redirect_to=".$full_URL;
    
    if (($is_page_clients == 1) AND ($is_user_logged_in != 1))
    {
    	header("location: ".$redirect_URL);
    }

    You may need to change the http:// for https:// in the $redirect_URL depending on your server settings.

    7. In the /wp-content/themes/<<theme name>>/wpi folder, edit the unified_invoice_page_active.php file as follows:
    Replace the following code
    global $invoice, $wpi_settings;
    with

    global $post, $invoice, $wpi_settings;
    
    $domain = $_SERVER['HTTP_HOST'];
    $domain_extension = $_SERVER['REQUEST_URI'];
    $full_URL = $domain.$domain_extension;
    $is_page_invoice = is_page( 'invoice' );
    $is_user_logged_in = is_user_logged_in();
    $redirect_URL = "http://".$domain."/wp-login.php?redirect_to=".$full_URL;
    
    if (($is_page_invoice == 1) AND ($is_user_logged_in != 1))
    {
    	header("location: ".$redirect_URL);
    }

    Again, you may need to change the http:// for https:// in the $redirect_URL depending on your server settings.

    So if you go directly to your client dashboard or to an invoice from an email link, you will be redirected to the WordPress login screen, which will redirect you once you have logged in to the appropriate client dashboard or individual invoice you were trying to see. You can replicate the code (with appropriate manipulation for the slugs of the pages) for the other templates (unified-invoice-page-paid.php, unified-invoice-page-refund.php etc).

    I know there are probably more elegant ways to achieve this, but while I was troubleshooting I added some extra steps, removed some pieces, and this is what I ended up with while still working. If you can clean it up, go for it.

    Hi James.

    (Sorry it took so long for me to respond – I only just noticed I was getting hits from this link, and saw your response ….)

    I have installed the update and that is great – the username pull-down and the gallery check boxes make managing this plug-in so much easier! Thanks for your work!

    Yep, you can, but it’s not quite as easy. I used the ID-Coppermine plug-in, and with a bit of work, got it going. But it was a little tricky to figure out. So hopefully my blog of the adventure makes it easier for you πŸ˜‰

    One thing I have figured out that isn’t covered by the plug-in is integrated security – you still have separate accounts and permissions across the two, both as an Admin and as a user. So if you have a password-protected gallery, you will need to log into Coppermine (not WP) to get through to the photos. If you want to upload files, you have to use Coppermine (not WP). I think it would be a nice touch to extend it out like that (as in, one account, both systems), but as it stands, that ain’t gonna happen.

    I don’t mean to turn you off Coppermine / WP integration – it can be done, but only to a point.

Viewing 3 replies - 1 through 3 (of 3 total)