0

I have a plugin that works for 99% of the users, but one user is having problems. The plugin opens a thickbox modal window and pushes content via the load-edit.php hook.

The links are displayed in a metabox like this:

add_action( 'add_meta_boxes_shop_order', 'add_box' );
function add_box() {
    add_meta_box( 'myparcel', __( 'MyParcel', 'wcmyparcel' ), 'create_box_content', 'shop_order', 'side', 'default' );
}


function create_box_content() {
    global $post_id;
    $export_link = wp_nonce_url( admin_url( 'edit.php?&action=wcmyparcel&order_ids=' . $post_id ), 'wcmyparcel' );
    ?>
    <a href="<?php echo $export_link; ?>" class="button myparcel one-myparcel" alt="Exporteer naar MyParcel">Exporteer naar MyParcel</a>
    <?php           
}

then I hook into load-edit.php:

add_action( 'load-edit.php', 'wcmyparcel_action' );
function wcmyparcel_action() {
    if ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'wcmyparcel' ) {
        // do stuff
    }
}

When this particular user tries to access that page, he gets the 'Are you sure you want to do this?' message. This indicates that the nonce fails (correct?), but I can't figure out why it's failing, especially since it's working for everybody else. As you can see I am not performing any nonce checks myself at this stage, so it fails before the action is even fired.

What can I do to diagnose the cause of this error?

those interested in the complete code, the plugin can be found here.

4
  • Maybe show the full code. That bits above are too less to give any real answer.
    – kaiser
    Feb 20, 2014 at 16:34
  • 1
    You should include some code in the actual question. But if it works for 99% my guess is that there is some sort of plug-in conflict - so you should find out which one and then start digging a bit further. But without some code demonstrating the problem we can't help... Feb 20, 2014 at 16:36
  • I'm sorry for not being complete, I added some code. I'm hesitant to paste all the code, because I think it doesn't really add any information. But if you still need more code, I'd be happy to paste the whole thing.
    – Ewout
    Feb 20, 2014 at 16:50
  • I have indeed found out that it's a conflict with another plugin. However, I have no idea where to start narrowing it down to the exact cause, any ideas.
    – Ewout
    Feb 20, 2014 at 17:00

1 Answer 1

1

Why are you using the edit.php page for this export link? The edit.php code appears to be checking on the "bulk-posts" nonce, which is probably where your failure is, since you're not using that nonce.

You should probably be using post.php instead, or a more general hook with your action.

1
  • I am using edit.php because the action is accessed from both the bulk actions and separate links. How come that it works normally but not with this specific plugin (it's "DP Pro Event Calendar", for what it's worth)? Also, note that I am actually outputting a new page in a modal window, which is why I used edit.php (and then exit when the page is generated)
    – Ewout
    Feb 21, 2014 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.