Disable


Home Forums Front End PM PRO Disable

This topic is: Resolved
Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #41577
    Shamim Hasan
    Keymaster

    Did you get the solution? Normally in wp json call if we do not pass X-WP-Nonce header it treats that call as non logged in user. You can check if this header is set or contact that plugin author and ask why get_current_user_id() is returning 0

    #41581
    jilllynndesign
    Participant

    I haven’t yet, but you’ve pointed me in the right direction. If I can make get_current_user_id() return the same user number as UPT()->get_user_id(), then the Send Message link should work on filtering/pagination, correct?

    #41583
    Shamim Hasan
    Keymaster

    get_current_user_id() should return current user id who is logged in and UPT()->get_user_id() should return user id whose profile is viewing.

    #41585
    jilllynndesign
    Participant

    Ah, so it should show MY user id when I’m viewing.

    #41587
    jilllynndesign
    Participant

    Found the solution! FacetWP includes this documentation:

    Pass authentication data through REST API requests:
    https://facetwp.com/pass-authentication-data-through-rest-api-requests/

    I needed to add the following code and now things work as they should:

    /*
      Please note that caching may interfere with the NONCE,
      causing ajax requests to fail. Please DISABLE CACHING for facet pages,
      or set the cache expiration to < 12 hours!
    */
    
    add_action( 'wp_footer', function() {
    ?>
    <script>
    (function($) {
      $(function() {
        FWP.hooks.addFilter('facetwp/ajax_settings', function(settings) {
          settings.headers = {
            'X-WP-Nonce': FWP_JSON.nonce
          };
          return settings;
        });
      });
    })(jQuery);
    </script>
    <?php
    }, 100 );
Viewing 5 posts - 16 through 20 (of 20 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.