Skip to content

Instantly share code, notes, and snippets.

@webhasan
Created March 28, 2020 16:51
Show Gist options
  • Save webhasan/79768ccd6e3708483f7f53ae5ab5dc1e to your computer and use it in GitHub Desktop.
Save webhasan/79768ccd6e3708483f7f53ae5ab5dc1e to your computer and use it in GitHub Desktop.
Nonce validation fix for logged out user with WooCommerce setuped
<?php
class My_Plugin {
public function hook() {
add_filter('nonce_user_logged_out', array($this, 'nonce_fix'), 100, 2);
}
public function nonce_fix($uid = 0, $action = ''){
$nonce_actions = array('pgfy-ajax-modal','pgfy-add-to-cart');
if(in_array($action, $nonce_actions)) {
return 0;
}
return $uid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment