• Resolved scsedel

    (@scsedel)


    Hi,

    I’m using successfully this great plugin since time now.
    I needed to use some hook in order to adjust prices and fees in my functions.php file. One of my hook checks if is_admin() is true in order to check if the dashboard is shown by a shop admin.
    In the last version of woocommerce, maybe, or of this plugin, I got an TRUE on is_admin() for customer in the review-order page, and this fails my routine and the plugin itself.
    Is this a known issue? is there any workaround to fix it? Why is_admin() returns TRUE during the pdf export even if it is a customer page?

    Thank you
    eddy

    https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi Eddy,
    The PDF is created via an AJAX request, and in AJAX, is_admin() always returns true (frontend or backend). This has not changed with the last version of WP, WC or this plugin 🙂
    However, it sounds like you don’t want to check whether you’re in the admin, but rather whether the person firing the action is an admin.
    You can do that with

    current_user_can('administrator')

    Hope that helps!
    Ewout

    Thread Starter scsedel

    (@scsedel)

    Hi Ewout,

    thank you! it solves the problem!
    I really don’t know how I couldn’t see the issue before, anyhow that’s all!

    Plugin Contributor Ewout

    (@pomegranate)

    Great, glad to hear that! Let me know if you have any other questions.
    And if you can spare a minute, I’d really appreciate a plugin review.

    Thanks!
    Ewout

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

The topic ‘pdf export fails, is_admin() true’ is closed to new replies.