• Greetings. I am building a plugin to allow logged-in users to submit articles of a custom post type via a front end form. When the article is submitted from a WYSIWYG editor, it displays as one huge paragraph block.

    How can I insert a form similar to this one used in the forum to submit questions via an editor that behaves like the Gutenberg editor?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator threadi

    (@threadi)

    The editor you used to write your post here in the forum is actually Gutenberg. As far as I know, the Blocks Everywhere plugin is used for this, which replaces the editor here in the bbPress-based forum with Gutenberg – in a slightly stripped-down version, since only a few formatting options are needed.

    You can try using this block plugin yourself. However, I’m not sure what your specific problem is right now. Which editor are you currently using for user input? It might just be a matter of sanitizing and formatting the submitted content accordingly. A concrete example of your current development status would be helpful so I can assist you more precisely.

    Moderator bcworkz

    (@bcworkz)

    I’m guessing your main sticking point is how to enforce a front end feature that’s only for logged in users. You could conditionally display a form or not by checking with is_user_logged_in(). The precise approach depends on whether you use a classic or block theme.

    Managing the form’s appearance may not be adequate security. For better security, you should verify server side if the user is not only logged in, but also has proper role capability to submit the form. There are a number of actions or filters that could be used to do this. For example, by using the "pre_post_insert" action.

    Thread Starter starapple

    (@starapple)

    @threadi , @bcworkz , thanks for your replies. I am creating a form for logged in users to submit a CPT, Articles, from the front to avoid access to the Admin area. I added an Editor field using Secure Custom Field but on opening the submission in Gutenberg, rather than the multiple paragraphs in the written article in the WYSIWYG editor, it appears as one big blob of a paragraph.

    Of course, it also displays in the published article as one huge paragraph, hence, I want to achieve the functionality of the Gutenberg editor that creates the correctly formated paragraph with a hard return.

    As @threadi, said, it is about sanitizing the inputs, which I think may be achieved by uskng an editor that emulates Gutenberg. This support forum I could recall using a stripped down Gutenberg editor for signed in users with limited roles.

    • This reply was modified 1 month, 1 week ago by starapple.
    • This reply was modified 1 month, 1 week ago by starapple.
    Moderator threadi

    (@threadi)

    As mentioned above, you’ll need to use Blocks Everywhere for this. It doesn’t just simulate Gutenberg – it is Gutenberg. Someone on their support forum will be able to tell you how to integrate it, unless it’s already documented somewhere on their GitHub-repo.

    If you want to stick with your current approach using a Secure Custom Field, I would recommend asking their support forum how to handle such input in PHP: https://wordpress.org/support/plugin/secure-custom-fields/ – I suspect some sanitize functions might be a possible solution here as well. However, since I’m not very familiar with the field you’re using or the plugin, I can’t say anything more specific about it.

    Thread Starter starapple

    (@starapple)

    Thanks @threadi. I’ll try the filter. Don’t want to use a plugin to solve a problem for a plugin I’m writing.

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

You must be logged in to reply to this topic.