bbress custom fields, auto-populate topic content
-
I have created custom fields for my bbpress topics, and I have learned how to auto-populate those fields when a user clicks a button. I have also learned how to auto-populate the Topic Title. I am using javascript to auto-populate the topic title. Here is how I assign the data:
$("input[name='bbp_topic_title']").val(data.title);
I am showing this as an example to show what I need. My question is; am I able to auto-populate the content of a new topic, much like I am doing with the title for a new topic?To auto-populate the content of a new topic, I assume I need to have the correct term, which I think would be ‘bbp_topic_content’? So it would look like this?
$("input[name='bbp_topic_content']").val(data.description);
Here are three functions I am using for custom fields:add_action ( 'bbp_theme_before_topic_form_content', 'bbp_extra_fields'); function bbp_extra_fields() { $value = get_post_meta( bbp_get_topic_id(), 'bookCover', true); echo '<label for="bookCover">Book Cover URL</label><br>'; echo "<p><input type='text' name='bookCover' value='".$value."'></p>"; } add_action ( 'bbp_new_topic', 'bbp_save_extra_fields', 10, 1 ); add_action ( 'bbp_edit_topic', 'bbp_save_extra_fields', 10, 1 ); function bbp_save_extra_fields($topic_id=0) { if (isset($_POST) && $_POST['bookCover']!='') update_post_meta( $topic_id, 'bookCover', $_POST['bookCover'] ); } add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields'); //add_action('bbp_template_before_main_content', 'bbp_show_extra_fields'); function bbp_show_extra_fields() { $topic_id = bbp_get_topic_id(); $valuec = get_post_meta( $topic_id, 'bookCover', true); }
I am thinking that I need some sort of “add_action” to get this accomplished? Do I need to create a new function? Any help would be GREATLY appreciated. Thanks.
- You must be logged in to reply to this topic.