1

我正在尝试创建一个 php 脚本来检查每个 bbpress 主题是否比某个日期更新,所以如果是这样,请将该主题的作者订阅到该论坛(我只有 1 个 bbpress 论坛,因此无需检查该论坛的ID)。

这是此时的代码:

<?php

$args = array(  
    'post_type'        => 'topic',  
);
$post = get_posts( $args ); 
$compare_date = strtotime( "2015-07-14" );

foreach($post->ID as $topic){
    $post_date    = strtotime( $post->post_date );
    $post_author_id = get_post_field( 'post_author', $topic );
    if ( $compare_date < $post_date  ) {        
        bbp_add_user_forum_subscription($post_author_id ,1687); 
    }   
}
?>

其中 1687 是我希望他们订阅的论坛的 ID。

这不起作用,我将那段代码添加到我的 functions.php 文件中并重新加载了我的网站,但 phpmyadmin 中没有任何变化:

SELECT * FROM wp_usermeta WHERE meta_key LIKE '%wp__bbp_forum_subscriptions%'
4

0 回答 0