ContentLEAD / ContentLead-WP-Plugin

Wordpress 2.9+ plugin to import brafton news and video articles from our custom xml feed.
brafton.com/support/wordpress/
2 stars 1 forks source link

Add filter for author #13

Closed retlehs closed 11 years ago

retlehs commented 11 years ago

On shoretelsky.com we use a modified version of this plugin in order to set a random author for imported posts. By adding a filter for the author, we can use the core plugin without modifications and still have the functionality we need. Example code:

function random_author() {
  $randID = mt_rand(1,100);
  $post_author = '1';
  switch (true) {
    case ($randID <= 25):
      $post_author = '2';
      break;
    case ($randID > 25 AND $randID <= 50):
      $post_author = '3';
      break;
    case ($randID > 50 AND $randID <= 75):
      $post_author = '4';
      break;
    case ($randID > 75 AND $randID <= 100):
      $post_author = '5';
      break;
  }
  return $post_author;
}
add_filter('braftonxml_author', 'random_author');
superburgers commented 11 years ago

Hi, This seems like customized functionality that not everyone would need so I'm not sure it belongs in the regular importer. I will discuss it with the director and see.

Since we have many clients downloading from here I don't think we can let you contribute, but you're welcome to fork the importer and open issues as you see fit for these other errors. I don't know what specific errors you're referring to but we do make efforts to not have any php errors in our plugin.

retlehs commented 11 years ago

this doesn't affect anything at all, it simply adds a filter so that people can hook into the author and change it if they want. by default, it works as it always has.