Skip to:
Content
Pages
Categories
Search
Top
Bottom

Update status with multiple text fields


  • franxifra
    Participant

    @franxifra

    Hello,
    I’m trying to put more than one field in the Activity Post Form, and show that content as part of the activity.
    I was able to edit the post-form.php to add the text inputs under the #whats-new textarea, but what i want now is to add those fields to the content of the activity update.
    I’ve been looking around the files and i founded this code on the bp-activity-actions.php file:

    
    // Get activity info
    	$content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
    

    When i add to that variable the $_POST[‘my-field’] nothing happens, is this the code that submit the content of the update to the database?

    I’ll really appreciate your help and sorry if i’m not using the right BP technical terms i’m quite new at this!

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)

  • modemlooper
    Moderator

    @modemlooper

    You should add extra fields as meta

    function add_meta_to_activity( $content, $user_id, $activity_id ) {
    
        bp_activity_update_meta( $activity_id, 'key', $_POST['value'] );
    
    }
    add_action( ‘bp_activity_posted_update’, ‘add_meta_to_activity’, 10, 3 );

    franxifra
    Participant

    @franxifra

    Thank you for your quick answer, I’ve to add that code to bp-custom.php right?


    modemlooper
    Moderator

    @modemlooper

    and add a input field in the post form. you can then call the activity meta in your activity loop.


    franxifra
    Participant

    @franxifra

    The code is working fine, the meta activity is created, but the only problem is that meta_value is empty, I’ve checked that the input name and $_POST value but still nothing!

    This is my code on bp-custom.php

    function add_meta_to_activity( $content, $user_id, $activity_id ) {
    
        bp_activity_update_meta( $activity_id, 'option1', $_POST['option1'] );
    
    }
    add_action( 'bp_activity_posted_update', 'add_meta_to_activity', 10, 3 );
    

    and this code on post-form.php inside the form tag

    <li>option <input name="option1" id="option1" type="text" /></li>

    any ideas why is not taking the $_POST value?

    Thank you one more time for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Update status with multiple text fields’ is closed to new replies.
Skip to toolbar