Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • Robin W
    Participant

    @robin-w

    After kicking this around, I found that

    add_filter( ‘tiny_mce_before_init’, ‘cac_enable_mentions_in_group_forum_tinymce’, 10, 2 );

    is never fired, presume this is an order thing.

    After some further research, I created a small plugin that has some much of the above, but also some js that executes for the visual version.

    available at

    bbp Mentions Suggest


    Robin W
    Participant

    @robin-w

    @r-a-y

    I know this is an old thread, but I can’t get your excellent code working for tinymce on topic/reply front end.

    Works fine in tinymce on backend, Works fine for textarea on front end, but not timymce on front end. I need it working on frontend in forums.

    Is there a more up to date version that works with current bp and bbp, or do you have any ideas how to get it working.

    the code I am using is

    /**
     * Enable at-mention autocomplete on BuddyPress group forum textareas.
     */
    function my_enable_mentions_in_group_forum_textareas( $retval ) {
    	$bbpress = false;
    
    	// Group forum reply.
    	if ( bp_is_group() && 'topic' === bp_action_variable() && bp_action_variable( 1 ) ) {
    		$bbpress = true;
    	}
    
    	// Group forum topic.
    	if ( bp_is_group() && bp_is_current_action( 'forum' ) ) {
    		$bbpress = true;
    	}
    
    	// Do stuff when on a group forum page.
    	if ( true === $bbpress ) {
    		$retval = true;
    		
    		// Ensure at-mentions autocomplete works with TinyMCE for bbPress.
    		add_filter( 'tiny_mce_before_init', 'cac_enable_mentions_in_group_forum_tinymce', 10, 2 );
    	}
    
    	return $retval;
    }
    add_filter( 'bp_activity_maybe_load_mentions_scripts', 'my_enable_mentions_in_group_forum_textareas' );
    
    /**
     * Ensure at-mentions autocomplete works with TinyMCE for bbPress.
     *
     * @param array  $settings   An array with TinyMCE config.
     * @param string $editor_id Unique editor identifier, e.g. 'content'.
     * @return array  $mceInit   An array with TinyMCE config.
     */
    function cac_enable_mentions_in_group_forum_tinymce( $settings, $editor_id ) {
    	// Add bbPress' editor IDs to enable BP mention autocomplete.
    	if ( 'bbp_topic_content' === $editor_id || 'bbp_reply_content' === $editor_id ) {
    		$settings['init_instance_callback'] = 'window.bp.mentions.tinyMCEinit';
    	}
    
    	return $settings;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar