Skip to:
Content
Pages
Categories
Search
Top
Bottom

Loading A Custom Form Only For Specific BuddyPress Groups


  • theumbrellaagency
    Participant

    @theumbrellaagency

    Hi there,

    I created a couple of custom fields and integrated it with my Group Topics, new topic form. I’d like to be able to just load this new form for specific groups. I ended up creating a little plugin to load the following code found on a tutorial that worked for me.

    It took a long time to figure this out and I was hoping to get a bit of direction to expedite figuring this out (the topic of this thread).

    Thanks!

    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″>Seeking Funding? (Yes or no)</label><br>’;
    echo “<input type=’text’ name=’bbp_extra_field1′ value='”.$value.”‘><br>”;

    $value = get_post_meta( bbp_get_topic_id(), ‘bbp_extra_field2’, true);
    echo ‘<label for=”bbp_extra_field2″>Resources Needed (talent, knowledge, mentors, etc.)</label><br>’;
    echo “<input type=’text’ name=’bbp_extra_field2′ value='”.$value.”‘>”;
    }

    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 “Seeking Funding? “.$value1.”<br>”;
    echo “Resources Needed: “.$value2.”<br>”;
    }

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