Notifications
Clear all

[Solved] Line Break with enter/return key

10 Posts
3 Users
6 Reactions
916 Views
gorgeousjorge
Posts: 25
Topic starter
(@gorgeousjorge)
Eminent Member
Joined: 10 months ago

Hi.

Trying to understand the line break/paragraph thing.
Iยดm developing a forum and my goal is to have the enter key making a line break and not a paragraph, just like in other editors.

Users are not going to use the shift+enter to make a line break.
Can this be done in wpforo/wordpress?

I mean pressing enter creates a line break, and if i want a paragraph then shift+enter; the opossite of whats now.

Thanks.

9 Replies
Sofy
Posts: 4900
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

@gorgeousjorge

There are the following keys in the wpForo:

  • Shift+Enter adds a line break (<br/>).
  • Pressing Enter creates a paragraph (<p></p>), resulting in two line breaks

There is no option to customize these key behaviors.

Reply
gorgeousjorge
Posts: 25
Topic starter
(@gorgeousjorge)
Eminent Member
Joined: 10 months ago

Hi and thanks for the clarification.

It`s a real "deal breaker" in a forum, who`s gonna use shift+enter to do a line break?

Everyone just presses enter and that`s it.

There are no plugins and/or css code to change that behavior?

Iยดm very sorry to read that.

Anyway thanks for your input.

Best regards.

Reply
Tutrix
Posts: 1493
(@tutrix)
Noble Member
Joined: 5 years ago

Posted by: @gorgeousjorge

There are no plugins and/or css code to change that behavior?

if this is so important to you, you can deactivate the p tag for new lines and activate the br instead

edit > wpforo > classes > Template.php

search for (topic + post)

'wpautop' => false,

and add these 2 lines of code below it

'force_br_newlines'       => true,
'force_p_newlines'        => false,

ย 

Reply
gorgeousjorge
Posts: 25
Topic starter
(@gorgeousjorge)
Eminent Member
Joined: 10 months ago

Tutrix, thank you it works.

Reply
1 Reply
Sofy
 Sofy
Admin
(@sofy)
Joined: 7 years ago

Support Team
Posts: 4900

@gorgeousjorge

The solution provided by Tutrix is correct. However, please note that you'll need to make these changes each time wpForo is updated. To ensure update safety, please use the following hook-code:

add_filter( 'wpforo_editor_settings', function($editor_settings){
    $editor_settings['tinymce']['force_br_newlines'] = true;
    $editor_settings['tinymce']['force_p_newlines']  = false;
    return $editor_settings;
} );

Instruction: How to Easily Add Custom Code in WordPress (without Breaking Your Site)

Reply
Page 1 / 2