Disable


Home Forums Front End PM PRO Disable

This topic is: Resolved
Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #41249
    jilllynndesign
    Participant

    Hi! I’m using the following code to add links to the Front End PM from another page:

    USER ) ); ?>">Send Message

    Question: if the user has messages disabled in settings, is there a way not to display this link? Or a conditional tag/function/something I can wrap around that code so it doesn’t display if user has messages disabled?

    #41252
    shamim
    Keymaster

    Then you need to add code in php. Check fep_current_user_can( 'send_new_message' ) before that link output.

    #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.

    #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 } ?>

    #41258
    shamim
    Keymaster

    You can wrap your code between back ticks.

    Which user message is disabled? Sender or receiver? From where they disable the message?

    #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>

    #41263
    shamim
    Keymaster

    I think UPT()->get_user_id() is receiver user id in your code. So you can use like fep_current_user_can( 'send_new_message_to', UPT()->get_user_id() )

    #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 } ?>
    #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 } ?>
    #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!

    #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?

    #41550
    shamim
    Keymaster

    Can you please check if UPT()->get_user_id() return correct user id?
    Also please add an else statement and see if that is echoing.

    Let me know.

    #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.
    #41567
    shamim
    Keymaster

    Can you please echo get_current_user_id(), fep_current_user_can( 'send_new_message_to', UPT()->get_user_id() ) and UPT()->get_user_id() in else statement? Also please check both user ids output correct ones.

    Let me know.

    #41569
    jilllynndesign
    Participant

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

Viewing 15 posts - 1 through 15 (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.