Skip Navigation

[Resolved] Display post edit text area as a plain text box in CRED form

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 7 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#563181

Hi there,

This ticket is a branch from the one I created here ( https://toolset.com/forums/topic/category-selection-in-cred-form/ ) where I foolishly added two issues to the same ticket. I will recap the issue here in this ticket, and then outline my follow-up question.

So my original question was: "Is it possible to display the post edit text area as a plain text box (i.e. remove the styling options on the front end, so the user can only submit standard paragraphs)?".

Christian replied with a great response as usual, essentially with two pieces of advice:

  • On standard WP posts add a multiline custom field to Posts, or use the excerpt field instead, and remove the editor field from your CRED form.
  • On a custom post type disable the post content field and use a separate (multiline) custom field instead

Christian also pointed out that there is in fact a way to move the content entered in a custom field with CRED into the post body. He said that this is done using the cred_save_data hook.

He said: "If you need additional assistance with this, please open a separate ticket so we can address that issue individually". So that's what I'm doing here, thank you.

If you could help me to understand how to do this (i.e. move the content entered in a custom field with CRED into the post body) I would greatly appreciate it. And if this is setup, then once someone enters a post using this method and it is stored in the post body in wp-admin, what happens when they return to an edit form with CRED? Would they still be able to edit that same content in a standard multiline text area custom field, and update again to the post body?

Many thanks again for your help.

Very best wishes,
Andrew.

#563297

Here's how you copy the content from a custom field and insert it into the post content:

add_action('cred_save_data', 'cred_multiline_action',10,2);
function cred_multiline_action($post_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==12345 || $form_data['id']==6789)
    {
      $post = array(
        'ID' => $post_id,
        'post_content' => $_POST['wpcf-multiline']
      );
      wp_update_post($post);
    }
}

Replace 12345 with your new CRED form ID, and 'wpcf-multiline' with the slug of your custom field, including the 'wpcf-' prefix. More information about the 6789 id below.

what happens when they return to an edit form with CRED? Would they still be able to edit that same content in a standard multiline text area custom field, and update again to the post body?
Yes, the original custom field content will remain stored with the post. So if someone edits the post with CRED, they can modify their original field content and the post's body content will be updated as well. Note - this edit form will have a different ID, so you can see above how I have added another form, 6789 to the conditional. You will need to replace that with the ID of your CRED edit form.