最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Add an extra field to BuddyPress activity form

programmeradmin2浏览0评论

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;
}

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;
}
Share Improve this question asked Dec 20, 2019 at 19:03 HuanHuan 111 bronze badge 1
  • 3rd party plugin questions are off-topic, try buddypress/support – RiddleMeThis Commented Dec 20, 2019 at 19:40
Add a comment  | 

1 Answer 1

Reset to default 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']
}
发布评论

评论列表(0)

  1. 暂无评论