jilllynndesign

Forum Replies Created

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • in reply to: Disable #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 );
    in reply to: Disable #41585
    jilllynndesign
    Participant

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

    in reply to: Disable #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?

    in reply to: Disable #41569
    jilllynndesign
    Participant

    Ah, get_current_user_id() is returning 0 when filtering/pagination is in use. It returns correctly on page load/refresh.

    in reply to: Disable #41561
    jilllynndesign
    Participant

    Yes, UPT()->get_user_id() is returning the correct user id.

    And, I added an else statement which is echoing whether filters/pagination are used.

    I’m attaching two screenshots in case that helps.

    Here is the relevant code:

    <?php echo UPT()->get_user_id(); ?><br>
    
    <?php if ( fep_current_user_can( 'send_new_message_to', UPT()->get_user_id() )) { ?>
    <a class="text-link" href="<?php echo fep_query_url('newmessage', array('fep_to' => UPT()->get_user_id() ) ); ?>">Send Message</a>
    <?php } else { ?>
    This is an else statement test
    <?php } ?>
    Attachments:
    You must be logged in to view attached files.
    in reply to: Disable #41545
    jilllynndesign
    Participant

    Hey Shamin – I have one more thing regarding the FacetWP + Send Message link integration I was hoping you could help me with.

    The Send Message link that looks like this…

    <?php if ( fep_current_user_can( 'send_new_message_to', UPT()->get_user_id() )) { ?>
    <a class="text-link" href="<?php echo fep_query_url('newmessage', array('fep_to' => UPT()->get_user_id() ) ); ?>">Send Message</a>
    <?php } ?>

    …works great on page refresh. BUT, when used in conjunction with FacetWP’s pagination or filtering, it doesn’t show up.

    I need to wrap it in ‘facet-loaded’. Here’s an example using this to reinitialize Jetpack’s Lazy Load after an ajax refresh:

    <script>
    (function($) {
        $(document).on('facetwp-loaded', function() {
            jetpackLazyImagesModule( $ );
         });
    })(jQuery);
    </script>

    Can you help me figure out what needs to be included for Front End PM to reinitialize after an ajax refresh?

    jilllynndesign
    Participant

    Works perfectly. Thank you!

    jilllynndesign
    Participant

    That worked perfectly. Thank you!!

    in reply to: Disable #41269
    jilllynndesign
    Participant

    Nevermind, I figured it out! I had to login as a different user to test it out. Then I could see the ‘Send Message’ link on my other user.

    Apparently, you can’t message yourself hence the link not showing up. LOL 🙂

    Thank you SO MUCH for your help, and sorry for the troubles!

    in reply to: Disable #41267
    jilllynndesign
    Participant

    Sorry, I included the wrong code. Here’s the correct one I’m using:

    <?php if ( fep_current_user_can( 'send_new_message_to', UPT()->get_user_id() )) { ?>
    <a class="text-link" href="<?php echo fep_query_url('newmessage', array('fep_to' => UPT()->get_user_id() ) ); ?>">Send Message</a>
    <?php } ?>
    in reply to: Disable #41265
    jilllynndesign
    Participant

    That hides the link for everyone. But the link doesn’t display if the receiver has unchecked “Allow others to send me messages?” in Settings.

    <?php if ( fep_current_user_can( 'send_new_message_to', $attendee_id )) { ?>
    <a class="text-link" href="<?php echo fep_query_url('newmessage', array('fep_to' => UPT()->get_user_id() ) ); ?>">Send Message</a>
    <?php } ?>
    in reply to: Disable #41260
    jilllynndesign
    Participant

    Thanks for the tip on the back ticks!

    If receiver has unchecked “Allow others to send me messages?” in Settings, I want to disable/hide:

    <a class="text-link" href="<?php echo fep_query_url('newmessage', array('fep_to' => $attendee_display_name ) ); ?>">Send Message</a>

    in reply to: Disable #41256
    jilllynndesign
    Participant

    Uh, my code keeps getting cut off and I can’t seem to Edit my reply.

    <?php
    $attendee_info = get_userdata(UPT()->get_user_id());
    $attendee_display_name = $attendee_info->user_nicename;
    } ?>

    <?php if (fep_current_user_can( ‘send_new_message’ )) { ?>
    $attendee_display_name ) ); ?>”>Send Message
    <?php } ?>

    in reply to: Disable #41254
    jilllynndesign
    Participant

    I added the PHP but it isn’t working to remove the link. Here’s the entire code:

    <?php
    $attendee_info = get_userdata(UPT()->get_user_id());
    $attendee_display_name = $attendee_info->user_nicename;
    } ?>

    <?php if (fep_current_user_can( ‘send_new_message’ )) { ?>
    $attendee_display_name ) ); ?>”>Send Message
    <?php } ?>

    The get_userdata(UPT()->get_user_id()); comes from FacetWP’s User Post Type plugin as I’m using it to create an attendee listing.

Viewing 14 posts - 1 through 14 (of 14 total)