Disable


Home Forums Front End PM PRO Disable

This topic is: Resolved
Viewing 10 posts - 1 through 10 (of 10 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!

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