BuddyDev

Search

Simple Textarea?

  • Participant
    Mark Power on #50848

    How would I go about adding a plain textarea to the registered field types?
    I’m having to make do with the Multi-line Text Area, but I don’t want all the editor toolbar stuff that comes with it.

    Would it be simpler to remove all that unwanted stuff?

  • Participant
    Level: Enlightened
    Posts: 22
    Michael on #50851

    Hi Mark
    This might possibly be of assistance?
    Will remove the editor toolbar stuff.
    Simply replace 9999 with your field id.

    
    function antipole_remove_rich_text( $field_id = null ) {
        if ( ! $field_id ) {
            $field_id = bp_get_the_profile_field_id( '9999' ); // replace 9999 with your field id
        }
     
        $field = xprofile_get_field( $field_id );
      
        if ( $field ) {
            $enabled = false;
        }
    }
    add_filter( 'bp_xprofile_is_richtext_enabled_for_field', 'antipole_remove_rich_text' );
    
  • Keymaster
    (BuddyDev Team)
    Posts: 24237
    Brajesh Singh on #50874

    Hi Mark,
    Thank you for the question. You may use on of the following:-

    1. Disable for all text area:-

    
    
    add_filter( 'bp_xprofile_is_richtext_enabled_for_field', function ( $enabled, $field_id ) {
    
    	$enabled = false; // disable for all text area.
    
    	return $enabled;
    }, 10, 2 );
    
    

    2. Or disable for specific text areas

    
    
    add_filter( 'bp_xprofile_is_richtext_enabled_for_field', function ( $enabled, $field_id ) {
    
    	$textarea_field_ids = [ 25, 45 ]; // your text area field ids, Please update
    
    	if ( $field_id && in_array( $field_id, $textarea_field_ids ) ) {
    		$enabled = false; // disable for the specific text area.
    	}
    
    	return $enabled;
    }, 10, 2 );
    
    

    Please feel free to use as you please.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved