• Resolved atmojones

    (@atmojones)


    I added this code to my functions.php file to keep unapproved users from sending messages. As far as I can tell the code in the function callback is never run. Any ideas why filter isn’t being applied?

    function myfs_bpro_gate_compose( $allowed ) {
    	if (bp_is_messages_compose_screen()) {
    		$allowed = false;
    	}
    
    	return $allowed;
    }
    add_filter( 'bprwg_buddypress_allowed_areas', 'myfs_bpro_gate_compose' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter atmojones

    (@atmojones)

    I found the reason but I’m not sure why it makes sense. In the core file for the plugin there is:

    function bp_registration_deny_access() {
    
    	$user = new WP_User( get_current_user_id() );
    	$private_network = (bool) get_option( 'bprwg_privacy_network' );
    
    	if ( $private_network ) {
    
    		if ( bp_registration_buddypress_allowed_areas() ) {
    			return;
    		}
    
    		if ( bp_registration_bbpress_allowed_areas() ) {
    			return;
    		}

    I used the filter in bp_registration_buddypress_allowed_areas() [which the code in my callback seems to be running now] to return false. Because it’s false it continues to execute an calls bp_registration_bbpress_allowed_areas() which returns true, and displays the message composition page. Once I used the filter in both functions it works. I feel like this is a bug, why wouldn’t you check bbpress and buddypress allowed areas in one function so they don’t both need to be addressed when overriding? Is it possible that plugins or custom code I am running is the cause of bbpress returning true? I’ll try to test on clean install later this week.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Good day @atmojones

    This feels like an edge case, truth be told.

    The reason why I don’t check for both BuddyPress and bbPress in the same if statement is because ideally, the user should be able to use either plugin, and have ours work. It’s not technically exclusive to BuddyPress, or at least I’m trying to steer it that direction.

    If I’m reading correctly, the BuddyPress check is working fine, and the message screen is properly being marked as not allowed. However, the bbPress check is returning true and thus exiting out of the deny access function, and the message screen is in result, shown like not intended.

    Biggest question I have is ow are they accessing messages screen in your scenario? At least if not in private network mode. If they’re able to get their via typing in the url directly (as an example), and the site is only in “users must be approved” mode, then that’s a situation I think I need to find a way to handle from the core plugin.

    Thread Starter atmojones

    (@atmojones)

    Thanks for your thorough response. I’m not sure if this is an edge case because some other plugin is interfering with this plugin. Once I’ve checked the functionality on a clean install I will get back to you.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    My question about how the screen is getting accessed is still my biggest curiosity point, for what it’s worth at the moment.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trying to gate buddypress message compose screen’ is closed to new replies.