When a node with body text format as plain_text is posted by anonymous user , how do I change it to full_html when being edited by admin or authenticated user?

Is there anyway I can edit body fields text_format on the go? like through preprocessing or form hooks?

I also have cases where some of the nodes when edited by admin comes with "enable/disable richtext", and for some nodes, it does not show up.

1 Answer 1


I'm afraid what I assume you are trying to accomplish just isn't available to you because Drupal saves the text entered in a field unfiltered/as is; it then filters it when it is actually displayed or rendered.

So, if you enter for example:

<b>Hello world</b> <some html tag>blah blah blah</end some html tag>

in a text field, that exact content will be saved.

Then, when the entity is displayed, Drupal will look at the text format and if it's plain_text, it will output

Hello world blah blah blah

but if the text format is full html it will output (with minor exceptions)

<b>Hello world</b> <some html tag>blah blah blah</end some html tag>

but once again, in both instances whatever the user inputs will be stored in the database.

Of course, you could create a field that toggles some sort of "display the body with full html after an admin has verified its contents" that would be looked at and if set, display the entity with that field using full html, but until set, would just display it in plain text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.