post_type ) { update_user_meta( $post->post_author, 'last_published', $post->post_date ); } } /** * Log plugin activations and deactivations. * * @param string $plugin * @param bool $network_wide * @return void */ function activated_plugin( $plugin, $network_wide ) { if ( $plugin == 'authors-by-latest-post' ) { $this->bulk_update(); } } function bulk_update() { $wp_user_query = new WP_User_Query( array( 'role__not_in' => 'Subscriber' ) ); $authors = $wp_user_query->get_results(); if ( !empty( $authors ) ) { foreach ($authors as $author) : $author_id = $author->ID; $query = self::get_post_query( $author_id ); foreach ( $query->posts as $recent_post ) : update_user_meta( $author_id, 'last_published', $recent_post->post_date ); endforeach; endforeach; } } } new Authors_By_Latest_Post_Update;