Home › Forums › Front End PM PRO › Disable
- This topic has 19 replies, 2 voices, and was last updated 4 years, 1 month ago by jilllynndesign.
-
AuthorPosts
-
October 9, 2020 at 2:09 am #41249jilllynndesignParticipant
Hi! I’m using the following code to add links to the Front End PM from another page:
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?
October 9, 2020 at 10:30 am #41252Shamim HasanKeymasterThen you need to add code in php. Check
fep_current_user_can( 'send_new_message' )
before that link output.October 9, 2020 at 7:34 pm #41254jilllynndesignParticipantI 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.
October 9, 2020 at 7:37 pm #41256jilllynndesignParticipantUh, 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 } ?>October 9, 2020 at 8:00 pm #41258Shamim HasanKeymasterYou can wrap your code between back ticks.
Which user message is disabled? Sender or receiver? From where they disable the message?
October 9, 2020 at 8:11 pm #41260jilllynndesignParticipantThanks 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>
October 9, 2020 at 10:43 pm #41263Shamim HasanKeymasterI think
UPT()->get_user_id()
is receiver user id in your code. So you can use likefep_current_user_can( 'send_new_message_to', UPT()->get_user_id() )
October 9, 2020 at 11:54 pm #41265jilllynndesignParticipantThat 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 } ?>
October 9, 2020 at 11:56 pm #41267jilllynndesignParticipantSorry, 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 } ?>
October 10, 2020 at 12:09 am #41269jilllynndesignParticipantNevermind, 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!
October 27, 2020 at 8:45 pm #41545jilllynndesignParticipantHey 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?
October 28, 2020 at 11:34 am #41550Shamim HasanKeymasterCan 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.
October 28, 2020 at 8:08 pm #41561jilllynndesignParticipantYes, 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.October 29, 2020 at 1:04 am #41567Shamim HasanKeymasterCan you please echo
get_current_user_id()
,fep_current_user_can( 'send_new_message_to', UPT()->get_user_id() )
andUPT()->get_user_id()
in else statement? Also please check both user ids output correct ones.Let me know.
October 29, 2020 at 3:42 am #41569jilllynndesignParticipantAh, get_current_user_id() is returning 0 when filtering/pagination is in use. It returns correctly on page load/refresh.
-
AuthorPosts
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.