Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25471

    Please use the following code instead.

    
    
    /**
     * Remove groups from user profile based on member type.
     */
    function buddydev_remove_group_based_on_member_types() {
    	if ( ! bp_is_user() ) {
    		return;
    	}
    
    	$user_id = bp_displayed_user_id();
    
    	if ( ! bp_has_member_type( $user_id, 'agent' ) ) {
    		bp_core_remove_nav_item( 'groups' );
    
    		$access = bp_core_can_edit_settings();
    		$friends_link = bp_displayed_user_domain()? bp_displayed_user_domain() : bp_loggedin_user_domain();
    		$friends_link = trailingslashit( $friends_link . bp_get_friends_slug() );
    		bp_core_new_subnav_item(array(
    			'name'            => __( 'Invitations', 'buddypress' ),
    			'slug'            => 'invites',
    			'parent_url'      => $friends_link,
    			'parent_slug'     => bp_get_friends_slug(),
    			'screen_function' => 'buddydev_groups_screen_group_invites',
    			'user_has_access' => $access,
    			'position'        => 30
    		));
    		// move the invitations to the friends screen.
    	}
    }
    
    add_action( 'bp_setup_nav', 'buddydev_remove_group_based_on_member_types', 1001 );
    
    /**
     * Helps us detect screen.
     */
    function buddydev_groups_screen_group_invites() {
        add_action( 'groups_screen_group_invites', 'buddydev_load_invite_template' );
    	groups_screen_group_invites();
    }
    
    /**
     * Load our template.
     */
    function buddydev_load_invite_template() {
        add_action( 'bp_template_content', function () {
            bp_get_template_part('members/single/groups/invites');
        });
    
    	bp_core_load_template('members/single/plugins' );
    }
    
    /**
     * Change the invite link url for the non 'agent' users.
     *
     * @param string $link original link.
     *
     * @return string
     */
    function buddydev_update_group_invite_link( $link ) {
        // for agent, do not break it.
        if ( bp_has_member_type( bp_loggedin_user_id(), 'agent' ) ) {
           return $link;
        }
    
    	global $groups_template;
    
    	if ( empty( $group ) ) {
    		$group =& $groups_template->group;
    	}
    
    	$friends_url = bp_loggedin_user_domain() . bp_get_friends_slug() .'/invites/';
    	$url         = trailingslashit( $friends_url . 'accept/' . $group->id );
    	$url         = add_query_arg( array( 'redirect_to' => $friends_url  ), $url );
    
    	//
    	return wp_nonce_url( $url, 'groups_accept_invite' );
    }
    
    add_filter( 'bp_get_group_accept_invite_link', 'buddydev_update_group_invite_link' );
    
    /**
     * Change the reject link url for the non 'agent' users.
     *
     * @param string $link original link.
     *
     * @return string
     */
    function buddydev_update_group_reject_link( $link ) {
        // for agent, do not break it.
        if ( bp_has_member_type( bp_loggedin_user_id(), 'agent' ) ) {
           return $link;
        }
    
    	global $groups_template;
    
    	if ( empty( $group ) ) {
    		$group =& $groups_template->group;
    	}
    
    	$friends_url = bp_loggedin_user_domain() . bp_get_friends_slug() .'/invites/';
    	$url         = trailingslashit( $friends_url . 'reject/' . $group->id );
    	$url         = add_query_arg( array( 'redirect_to' => $friends_url ), $url );
    
    	return wp_nonce_url( $url, 'groups_reject_invite' ) ;
    }
    
    add_filter( 'bp_get_group_reject_invite_link', 'buddydev_update_group_reject_link' );
    
    /**
     * Remove groups from adminbar based on member type.
     *
     * @param array $nav nav items.
     *
     * @return array
     */
    function buddydev_filter_show_hide_groups_in_adminbar( $nav ) {
    	if ( ! is_user_logged_in() ) {
    		return $nav;
    	}
    
    	if ( ! bp_has_member_type( bp_loggedin_user_id(), 'agent' ) ) {
    		$nav = array();
    	}
    
    	return $nav;
    }
    
    add_filter( 'bp_groups_admin_nav', 'buddydev_filter_show_hide_groups_in_adminbar' );
    
    

    It will work if you try to accept from the Friends->Invites screen.

    Problem:-
    – I don’t see a way for filtering the link in the email notification.
    – You also need code for filtering the link in the local notification(atleast 2 more filters).

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25471

    Thank you for the kind words Graham.

    Your kind words mean a lot. It’s pleasure to be part of our member’s success.

    All the best.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25471

    Hi PresPhuture,
    Thank you for posting.
    Yes, it is possible to control which category/tags are shown

    
    
    /**
     * Filter the BuddyBlog form settings and limit category/tag inclusion.
     *
     * @param array $settings settings array.
     *
     * @return array
     */
    function buddydev_filter_buddyblog_form_settings( $settings ) {
    
    	$tax                        = isset( $settings['tax'] ) ? $settings['tax'] : array();
    	$tax['category']['include'] = array( 1, 2, 3 );// category ids to include.
    	$tax['post_tag']['include'] = array( 5, 7, 9 );// tag ids to include.
    
    	$settings['tax'] = $tax;
    
    	return $settings;
    }
    
    add_filter( 'buddyblog_post_form_settings', 'buddydev_filter_buddyblog_form_settings' );
    
    

    Please change the ids with your own. It will only list the category tags with those ids. I hope you can modify it form there on.

    Hope that helps.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25471
    Brajesh Singh on in reply to: Debug issue list. Please update #12253

    Thank you. Please allow me to check for the Live notifications. Some of the legacy plugins may have notices.

    I appreciate you taking time to report and hep us fix it.

    regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25471

    Hi Ekiz,
    I see the problem. You are using ordered list while the code I posted allowed unordered list. I have updated the code to allow ordered list too now

    
    /**
     * Add remove filters to allow more tags.
     */
    function buddydev_add_remove_group_desc_filters() {
    	remove_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 );
    	add_filter( 'groups_group_description_before_save', 'bp_groups_filter_kses', 1 );
    }
    
    add_action( 'bp_loaded', 'buddydev_add_remove_group_desc_filters');
    
    /**
     * Allow extra tags in group description.
     *
     * @param $tags
     *
     * @return mixed
     */
    function buddydev_allow_extra_group_desc_tags( $tags ) {
        $tags['ul'] = array();
        $tags['ol'] = array();
        $tags['li'] = array();
        $tags['strong'] = array();
        $tags['b'] = array();
        return $tags;
    }
    add_filter( 'bp_groups_filter_kses', 'buddydev_allow_extra_group_desc_tags' );
    
    

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25471

    Hi Graham,
    There is no error with your code. Are you getting any fatal error or notice from the site after updating this code? You may ignore the editor warning. I don’t see any warning while using PHPStorm. which editor it is?

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25471
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25471

    Hi Beuza,
    It’s strange but quiet possible as we are moving the handlers and all.

    I was trying to avoid settings up it on local as I will need to recreate the whole thing, so Yes, It will be nice if you can give me an account who has the requests pending.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25471
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25471

    Hi,
    Yes, I too noted it. It seems the google doc viewer has somehow restricted the viewing of zip.

    I am going to put an update in next 1-2 days where zip files won’t be available as view able but just as an attachment.

    Thank you
    Brajesh