BuddyDev

Search

Replies

  • Participant
    Level: Enlightened
    Posts: 71

    Hello Brajesh,

    Thank you for your help.
    I will look into the plugin.

    Best Regards
    Lefteris

  • Participant
    Level: Enlightened
    Posts: 71

    The results that i am getting from the the 2 fields with var_dump are:

    for EVENT CATEGORIES

    <pre>array(2) {
      [0]=>
      string(164) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Walk</a></li></ul>"
      [1]=>
      string(152) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Dance</a></li></ul>"
    }
    </pre>

    for EVENT TAGS

    <pre>array(3) {
      [0]=>
      string(128) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Speak</a></li></ul>"
      [1]=>
      string(144) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Read</a></li></ul>"
      [2]=>
      string(128) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Think</a></li></ul>"
    }
    </pre>

    So the results looks the same.

  • Participant
    Level: Enlightened
    Posts: 71

    Thank you very much Brajesh for your kind help 🙂

    • This reply was modified 1 year, 5 months ago by Lefteris.
  • Participant
    Level: Enlightened
    Posts: 71

    Hello Brajesh,

    Thank you so much for your always kind help.
    This is what i was also thinking. A filter would be good.
    But still i am not so sure how i can create the entry after.

    When you will push the update could you please help me with the attachment entry?

    Thank you

  • Participant
    Level: Enlightened
    Posts: 71

    Hello Ravi and thank you very much for your time 🙂

    I believe this is sufficient enough for the time.

  • Participant
    Level: Enlightened
    Posts: 71

    Hello Ravi and thank you very much for your feedback 🙂

    I would say approx 30-40 users in total that are not with a subscriber role: array( 'contributor', 'author', 'administrator' ) .

    Thank you very much for your help

  • Participant
    Level: Enlightened
    Posts: 71

    Hello Ravi.
    I believe i’ve got it working but i am not sure if there is any mistake in my code. Could you also check it and confirm:

    
    
    function reminder_email() {
    	
           $today = strtotime( date( 'Y-m-d' ) ); // Get today's date
    	$args = array(
       'orderby' => 'post_date',
       'order' => 'DESC',
       'author' => '',
       'post_type' => 'post',
       'post_status' => 'publish',
       'posts_per_page' => 1,
    );
    
    $authors = get_users( array(
        'role__in' => array( 'contributor', 'author', 'administrator' ), // get only specific roles
        'fields' => array( 'ID' )
    ) );
    
    foreach ( $authors as $author ) {
       $args['author'] = $author->ID;
       $author_posts = new WP_Query( $args );
       if ( $author_posts->have_posts() ) {
    	   
         
    	   
          while ( $author_posts->have_posts() ) {
             $author_posts->the_post();
             $expire = strtotime( '+60 days', strtotime( $post->post_date ) ); //Calculation to compare the post_date of the last post's with today date (when is more than 60 days that author haven't published a new post)
    		 
             if ( $expire < $today ) {  wp_mail();  //send email reminder to get_the_author_meta( 'user_email' ) }
         
    	 }
       
       }
       wp_reset_postdata();
    }
    
    }
    add_action( 'reminder_email', 'reminder_email' );
    
    

    Thank you very much for your help 🙂

    • This reply was modified 1 year, 6 months ago by Lefteris.
  • Participant
    Level: Enlightened
    Posts: 71

    Hello Ravi

    Thank you so much for your help 🙂
    I was suspecting that your code is correct.
    I have tried many different examples of codes and i really can’t understand why it gives me wrong results.

    https://ibb.co/Z25Mw1x (keeps giving the oldest article)
    https://ibb.co/RND6Dm7

    It seems like the DESC doesn’t affect.

    What i am trying to do is similar to previous https://buddydev.com/support/forums/topic/send-email-to-user-that-has-been-inactive-for-2-months/ :

    With a cron job, send an email reminder to authors that have not published a post for the last 60 days.

    So i am trying to create my function, something like this :

    
    function reminder_email() {
    	
           $days = 60; // if these days have passed from the last published post of the author send email reminder
    
    	global $wpdb;
    	
    	// get the most recent post for each author
    	$posts = $wpdb->get_results();
    
    	// No post found.
    	if ( empty( $posts ) ) {
    		return;
    	}
    
    	
    	if ( ! empty( $posts ) ) { 
    	foreach( $posts as $post ) {
    	
            // get today's date in unix timestamp format
    		$today = strtotime( date( 'Y-m-d' ) );	
    		
    		// the date is X number of days from last post published date where X is set in the $days variable above
    		$expire = strtotime( '+'. $days .'days', strtotime( $post->post_date ) );
    		
    	$user_info = get_userdata( $post->post_author );
    	
    	if ( $expire < $today ) { wp_mail();  //send email reminder to $user_info->user_email  }
           }
    	}
    }
    add_action( 'reminder_email', 'reminder_email' );
    

    I don’t understand why results from db are wrong.

    • This reply was modified 1 year, 6 months ago by Lefteris.
  • Participant
    Level: Enlightened
    Posts: 71

    Hello Brajesh,

    Thank you for your help 🙂
    That was the problem indeed.

    Thank you so much!!

  • Participant
    Level: Enlightened
    Posts: 71

    Hello Ravi

    Thank you very much for your help 🙂
    Unfortunately it didn’t work. Keeps giving me the oldest article for each author.