Skip to:
Content
Pages
Categories
Search
Top
Bottom

Php script to subscribe people that has created a topic


  • Emineminero
    Participant

    @emineminero

    I’m trying to create a php script to check if each bbpress topic is newer than certain date, so if its 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 suscribe.

    Any idea why is not working?
    Thanks 🙂

  • You must be logged in to reply to this topic.
Skip to toolbar