Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

  • empressdianna
    Participant

    @empressdianna

    I don’t have an exact fix but I went into “Emails” from the WordPress Sidebar and edited the email that is sent on a new message sent trigger. I just took out the {{subject}} and {{quot}} tags and then just put a message that they have to login to view the message. hth


    empressdianna
    Participant

    @empressdianna

    Now if someone can help me send a generic notification message instead of the whole message that would be great….


    empressdianna
    Participant

    @empressdianna

    Found this on another forum and after some tweaking finally got this to work. This will only work if you force all new and existing non-paying users into one group however without some further tweaking. If a non-paying user tries to click on the “messaging” tab in wordpress it will redirect them to any page you choose. I chose the memberships level page. =D

    function bp_disable_messaging() {
    	global $bp;
    	
    	if ( pmpro_hasMembershipLevel('NonPayingLevel') && bp_is_current_component('messages') ) {
    		wp_redirect( site_url("/PAGE URL/") );
    		exit();
    	}
    }
    add_action('wp','bp_disable_messaging');

    empressdianna
    Participant

    @empressdianna

    Thank you so much for this code! I’ve spent several hours trying to use other people’s code to hide the button and even tried to make my own but nothing worked until I found your code. I just switched it around because I only wanted one particular group to not be able to send messages while the rest can.

    Posting in case someone in the future needs the opposite of your code:

    add_filter( 'bp_get_send_message_button', function( $array ) {
        if ( pmpro_hasMembershipLevel('NAMEOFPMPLEVEL') ) {
            return '';
        } else {
            return $array;
        }
    } );

    Also, I am looking for the same code as you to restrict non-paying users from sending private messages. I found a code that looks promising but unfortunately doesn’t work. It sees if the user is logged in and if not redirects them. Then if the person is logged in it checks their role but if they’re not that role they’re supposed to be redirected. But it just breaks my whole site. Any ideas?

    function my_function() {
    
        if ( ! is_user_logged_in() && bp_is_current_component( 'messages' ) ) {
            // Current user is not logged in so don't let them see stuff. In this case, private messages 
            wp_redirect( home_url() );
            exit;
        }
            
        $flag = false;
        // Get current user info.
        $user = wp_get_current_user();
    
        if ( ! in_array( 'student', $user->roles ) ) {
            // The current member is not a student.
            $flag = true;
        }
    
        if ( $flag && bp_is_current_component( 'messages' )  ) {
            The currently logged-in member is not a student and is trying to view private messaging. Let's redirect them away.
            wp_redirect( home_url() );
            exit;
        }
    }
    add_action( 'init', 'my_function' );
Viewing 4 replies - 1 through 4 (of 4 total)
Skip to toolbar