Wordpress front-end form to Discourse


#1

Hello,

I my forum, i want to create a recruitment form on Wordpress (because it’s the front page, and i don’t find form add-on on discourse), so i use the WP User Frontend add on to generate a WP post which will be creating on Discourse.
Problem: the discourse doesn’t synchronize the layout and it creates a dough like this (in french) :

essai Posté sur 9 avril 2018 par icka_admin J’ai lu et approuvé la charte: ouiVotre pseudo Wakfu: LonsdaleiteVotre classe principale: crâNiveau: 200Votre/vos ancienne(s) guilde(s): CroisadesAvez-vous des personnages dans d’autre guilde ?: ouiSi oui, laquelle/Lesquelles: InsomniaDepuis vos débuts, quel est votre parcours sur Wakfu et pourquoi nous avoir choisit ?: TestQu’attendez-vous des Rangers ?: testQu’attendez-vous des Rangers ?: testA quels autres jeux jouez-vous ?: Test Articles similaires

The WP User Frontend add doesn’t generate a text post, but a filled form in meta box below the text editor, so perhaps the meta box could be the problem ?
Someone uses a frontend form (free if possibly) to post on discourse ?

Thank for you help


(Simon Cossar) #2

Does the form generate any text that you would like to have published to Discourse? If so, there is a filter that can be used to set the text that is published to Discourse for a specific post type.

The filter is called wp_discourse_excerpt. If you can find out how to access the content you would like to publish, I can give you some code that will work to publish it to Discourse.


#3

The form is a recruitment form, so i would like to post all the content of the form with a layout (not a dough).
I don’t find the metabox, it doesn’t want to appear now so i can’t take a screenshot, but i will try.

So, if the wp_discourse_excerpt can published the entirely content, i wish, if it possible, your code and how i use/install it. (I am a beginner in PHP, i am juste an amateur to website creation ^^)


#4

So, the meta box doesn’t want to appear.

So, it’s a post the form generated, “Visuel” and “Texte” are empty, and below the commentary, there was the WPUF Meta Box with the filled form, and on discourse, there is a dough which can be see with a “see more” button.

I hope my english are not so bad


(Simon Cossar) #5

If you can find out how the WP User Frontend plugin saves the data that you want to publish, I can give you some code that you can try.

The data is probably saved as post_metadata. The developer of the WP User Frontend plugin will be able to tell you the name of the key under which it is saved.


(Anton) #6

How complex is your form?
An alternative is to develop a WP plugin that will either:

A) Hook into the WP User Frontend plugin (subscribe to its events) and use the data to public to Discourse through its API.

OR

B) make its own form and publish to Discourse API on form submission


#7

I don’t find the variable post_metadata anywhere, but i think i don’t search at the fine location, but i fond, in the source code, that all the field of the form (which are custom field, i forgot to mentionned that) are in the class wp_custom_field which depend of the metabox, so i think the custom field of the form is save in post_metabox.

What do you mean when you ask me “how complex is your form ?”
And i am not able to develop in PHP, i am not a dev, only a simple amateur who help to create a website :confused:


(Simon Cossar) #8

I installed the WP User Frontend plugin to see what it is doing. The easiest way to get nice looking posts published to Discourse is to publish an excerpt from the post. You will probably have to create the excerpts manually before you publish the post to Discourse.

To make this work, make sure the WP Discourse ‘Use Full Post Content’ option is not selected. Before you publish a post, add an excerpt to the Excerpt meta-box that is on the WordPress post-edit page. (You may need to enable the excerpt meta-box in the WordPress Screen Options menu. The excerpt should be published to Discourse. On Discourse, when someone clicks the Show Full Post button, they should see the properly formatted post.

There are other ways that this could be approached, but they all require some custom code.


(Raha Soleymanzadeh) #9

Would you please guide me how can I create the excerpts manually? I installed the discourse and Wordpress on localhost and also installed the WP-discourse, but I don’t know how can I publish to discourse from the posts.


#10

Thank for the solution, but i need fully autonomous form.

But i find other alternative with Caldera Form and Caldera Custom Field (after long research),
So if other people want to do a autonomous post form, i give you my solution :
After create a form on Caldera Form, create variables (which can include html code, form field and other variable), with the different form field and text like that : https://i.imgur.com/aDqgg3a.png
Now, in processing, create a “Save as post type”, and into content, you can choose the variable which contain all the others variable and some HTML code like that : https://i.imgur.com/QhJz6p3.png . It’s tedious, but it work.

thank you for your help