1

我正在尝试为类中的 bbPress 中的新主题填充一些自定义元数据。我可以使用此类成功提交元数据,但挂钩到新主题创建似乎不起作用。这是我正在使用的功能:

    // Set the default status on post submit
    public function default_status() {

        // Set status to open
        update_post_meta( $this->topic_id, $this->meta_key, 1 );

    } // default_status()

然后在构造函数中,我正在执行以下操作:

add_action( 'bbp_new_topic', array( &$this, 'default_status' ) );
4

1 回答 1

0

所以我最终通过将 topic_id 传递给钩子本身来完成这项工作,如下所示:

public function default_status( $topic_id = 0 ) {

    $default_status = 1;

    // Set status to open
    update_post_meta( $topic_id, $this->meta_key, $default_status );

} // default_status()
于 2014-09-08T01:08:10.050 回答