1

I want to add a custom text field in the BuddyPress activity form and save it. I can add it with this code:

add_action ( "bp_after_activity_post_form", 'my_test_function' );

function my_test_function(){
    echo '<div id="tags-content"> 
            <input type="text" name="tags" value="" />
        </div>';
}

How can I save it? I'm trying this, but it never goes to it.

add_action('bp_activity_after_save', 'where_activity_from', 10, 3);

function where_activity_from( $activity ) {
    echo "test";
    //die;
}
1
1

First of all, there is only 1 $accepted_args, not 3, so the add_action is:

add_action('bp_activity_after_save', 'where_activity_from', 10, 1);

Second, the value in your tags input is never parsed by BP_Activity_Activity->save() so how could it be part of the array available thru the hook?

Try using the $_POST array, like this:

add_action('bp_activity_after_save', 'where_activity_from', 10, 1);
function where_activity_from( $activity ) {
    // write_log( $_POST['tags'] );
    // do something with $_POST['tags']
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.