Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] visual editor for writing messages?

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

  • danbp
    Moderator

    @danbp

    You should read before installing a prototype plugin !

    This is a work in progress to illustrate what i have in mind for a next BuddyPress Template Pack. DO NOT USE on a live website! I repeat: DO NOT USE on a live website!

    If you want a visual editor, here’s a bit old solution. Give it a try, maybe it’s still working !


    binary10
    Participant

    @binary10

    @danbp
    I know its a prototype plugin and i installed it on a test website. Thanks for the link but it doesn’t work.
    I added the code to bp-custom.php and then edited buddypress/activity/members/single/messages/compose.php. I replaced <textarea name="content" id="message_content" rows="15" cols="40"> with <?php do_action( 'whats_new_textarea' ); ?>. It actually shows the visual editor but when the send message button is clicked it gives error Your message was not sent. Please enter some content. I am not much familiar with coding so maybe I am doing a mistake.
    thanks


    danbp
    Moderator

    @danbp

    yep! $content is not defined.

    Use this one instead. Successfully tested with 2015.

    function bpfr_whats_new_tiny_editor() {
    	// deactivation of the visual tab, so user can't play with template styles
    add_filter ( 'user_can_richedit' , create_function ( '$a' , 'return false;' ) , 50 );
    
    $content = "";
    
    	// building the what's new textarea
    	if ( isset( $_GET['r'] ) ) :
    	$content = esc_textarea( $_GET['r'] ); 
    	endif;
    
    	// adding tinymce tools
    	$editor_id = 'whats-new';
    		$settings = array( 
    		'textarea_name' => 'whats-new', 
    		'teeny' => true, 
      		'media_buttons' => true, 
    		'drag_drop_upload' => true, 
    		'quicktags' => array(
    		'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close'
                        )
                     );	
    	
    	// get the editor	
    	wp_editor( $content, $editor_id, $settings );
    }
    add_action( 'whats_new_textarea', 'bpfr_whats_new_tiny_editor' );

    binary10
    Participant

    @binary10

    @danbp thanks for the code snippet but it doesn’t work. I replaced the bp-custom.php code with the new one you provided but still getting the same error. After pasting the code in bp-custom.php i only have to replace the <textarea name="content" id="message_content" rows="15" cols="40"> with <?php do_action( 'whats_new_textarea' ); ?>, right?
    The generated HTML after adding the new code is <textarea class="wp-editor-area" rows="20" cols="40" name="whats-new" id="message_content"></textarea>
    What is going wrong?
    thanks


    danbp
    Moderator

    @danbp

    Sorry, my fault! I haven’t realised you mentioned /messages/compose.php

    The snippet is intended to work on the what’s new form, not the compose message form.

    To do this, we need the correct textarea name and another editor_id. Use this function:

    function bpfr_compose_msg_tiny_editor() {
    
    $content = "";
    	
    	if ( isset( $_GET['r'] ) ) :
    	$content = esc_textarea( $_GET['r'] ); 
    	endif;
    
    	$editor_settings = array(
    		'content' => bp_messages_content_value(),
    		'textarea_name' => 'content',
    		'editor_id' => 'message_content',
    		'teeny'=>true,
    		'media_buttons'=>false
    	);
    	wp_editor( bp_messages_content_value(), "message_content", $editor_settings); 
    }
    add_action( 'compose_edit_tools', 'bpfr_compose_msg_tiny_editor' );

    In compose.php, remove line 38
    <textarea name="content" id="message_content" rows="15" cols="40"><?php bp_messages_content_value(); ?></textarea>

    and replace it by

    <?php do_action( 'compose_edit_tools' ); ?>

    Visual and Text tab may be unecessary. You can hide them by adding this to your theme style.css:
    #wp-message_content-editor-tools {display:none!important;}

    To get the edit tools on the reponse editor, same trick, replace the textarea line 123 in /messages/single.php with the above action hook.


    binary10
    Participant

    @binary10

    @danbp awesome now its working 🙂 thanks


    bossataxiatogether
    Participant

    @bossataxiatogether

    Sorry @danbp but it is not working for replies.
    Keep getting “There was a problem sending that reply. Please try again.”
    So I guess there is something wrong with the content.

    Thanks in advance for looking into this 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] visual editor for writing messages?’ is closed to new replies.
Skip to toolbar