Skip to:
Content
Pages
Categories
Search
Top
Bottom

I would like to add 2 more textarea fields in "Create New Topic" page.


  • a298e
    Participant

    @honeybb

    Hello,

    I would like to add 2 more textarea fields in “Create New Topic” page in addition to an original textarea of bbPress.

    I added following code to function.php, but an original textarea of bbPress was disappeared and couldn’t become submit, error of “ERROR: Your topic cannot be empty. “.

    ——————————-
    add_action ( ‘bbp_theme_before_topic_form_content’, ‘bbp_extra_fields’);
    function bbp_extra_fields() {
    $value = get_post_meta( bbp_get_topic_id(), ‘bbp_extra_field1’, true);
    echo ‘<label for=”bbp_extra_field1”>textarea1</label><br>’;
    echo “<textarea name=’bbp_extra_field1′ rows=’10’ cols=’78’ value='”.$value.”‘></p>”;

    $value = get_post_meta( bbp_get_topic_id(), ‘bbp_extra_field2’, true);
    echo ‘<label for=”bbp_extra_field1″>textarea2</label><br>’;
    echo “<textarea name=’bbp_extra_field2′ rows=’10’ cols=’78’ 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[‘bbp_extra_field1’]!=”)
    update_post_meta( $topic_id, ‘bbp_extra_field1’, $_POST[‘bbp_extra_field1’] );
    if (isset($_POST) && $_POST[‘bbp_extra_field2’]!=”)
    update_post_meta( $topic_id, ‘bbp_extra_field2’, $_POST[‘bbp_extra_field2’] );
    }

    add_action(‘bbp_template_before_replies_loop’, ‘bbp_show_extra_fields’);
    function bbp_show_extra_fields() {
    $topic_id = bbp_get_topic_id();
    $value1 = get_post_meta( $topic_id, ‘bbp_extra_field1’, true);
    $value2 = get_post_meta( $topic_id, ‘bbp_extra_field2’, true);

    echo “textarea1: “.$value1.”<br>”;
    echo “textarea2: “.$value2.”<br>”;
    }
    ——————————-

    What I want to do is;

    ・There are 3 of textarea fields in “Create New Topic” page.
    ・After submitted, the content being input in 3 textarea are shown in 1 original posted textarea like,

    <p>
    content of textarea1
    </p>
    <p>
    content of textarea2
    </p>
    <p>
    content of textarea3
    </p>

    If anyone know it, please help me.

    Thanks,

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar