I’m trying to create a php script to check if each bbpress topic is newer than certain date, so if it’s true, subscribe the author of that topic to that forum (I only have 1 bbpress forum so there is no need to check the id of that forum).
This is the code at this point:
<?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);
}
}
?>
where 1687 is the id of the forum I want them to subscribe.
This is not working, I added that piece of code to my functions.php file and reloaded my website but nothing changed in phpmyadmin:
SELECT * FROM wp_usermeta WHERE meta_key LIKE '%wp__bbp_forum_subscriptions%'