admin管理员组

文章数量:1307787

User fills their user bio using Formidable forms.

It saves correctly and displays with line breaks in Worpdress admin on the user overview page.

It displays without line breaks on the site.

The only solution I found is to disable HTML sanitization and manually edit each profile and add <p> or <br> tags which is not an ideal solution. This is not ideal as it enables all HTML plus the need for manual edits of each profile.

What I would like is to display the line breaks as they were originally entered and saved in Wordpress. This would allow a simple workflow for users to add and update their profile without using HTML code.

Thanks.

User fills their user bio using Formidable forms.

It saves correctly and displays with line breaks in Worpdress admin on the user overview page.

It displays without line breaks on the site.

The only solution I found is to disable HTML sanitization and manually edit each profile and add <p> or <br> tags which is not an ideal solution. This is not ideal as it enables all HTML plus the need for manual edits of each profile.

What I would like is to display the line breaks as they were originally entered and saved in Wordpress. This would allow a simple workflow for users to add and update their profile without using HTML code.

Thanks.

Share Improve this question edited Jul 16, 2020 at 14:35 Jacob Peattie 44.1k10 gold badges50 silver badges64 bronze badges asked Jul 15, 2020 at 19:21 Adrian NutiuAdrian Nutiu 11 bronze badge 2
  • How are you currently displaying the bio on the site? – Jacob Peattie Commented Jul 16, 2020 at 14:35
  • @JacobPeattie in 2 ways: Elementor author profile widget and the theme author bio box. Also happy to use Advanced Custom Fields if that would make it easier. – Adrian Nutiu Commented Jul 16, 2020 at 19:26
Add a comment  | 

2 Answers 2

Reset to default 1

You could use "white-space: pre;" in CSS to display newlines as they are

You can use the nl2br PHP function. It means insert line breaks where newlines (\n) occur in the string. https://www.w3schools/php/func_string_nl2br.asp

example:

echo nl2br($userbio);

Hope this helps.

本文标签: Display the line breaks in user bio without using html