Viewing 6 replies - 31 through 36 (of 36 total)
  • Thread Starter Eduardo

    (@eduardoluism)

    Hi Frank,

    the code is not working. I also fixed a mistype here ‘in-stock-mdailer/v1’

    thank you.

    Plugin Author Frank

    (@frankspress)

    gotcha, still not working after the fix?

    Thread Starter Eduardo

    (@eduardoluism)

    no =(

    Plugin Author Frank

    (@frankspress)

    What’s the action you re using to hook the code in?

    Plugin Author Frank

    (@frankspress)

    add_action( 'rest_api_init', function() {
      if ( defined('REST_REQUEST') && strpos( $_SERVER['REQUEST_URI'], 'in-stock-mailer' ) ) {
        $send_no_cache_headers = apply_filters('rest_send_nocache_headers', is_user_logged_in());
        if (!$send_no_cache_headers && !is_user_logged_in() ) {
                  $_SERVER['HTTP_X_WP_NONCE'] = wp_create_nonce('wp_rest');
        }
      }
    }, $priority = 1 );

    Just tested this and it works.
    Let me know.

    Thread Starter Eduardo

    (@eduardoluism)

    Worked!

    I was using init.

Viewing 6 replies - 31 through 36 (of 36 total)
  • The topic ‘user not logged in’ is closed to new replies.