How can I stop the Devel module from generating blog/forum entries for Anonymous user? I'm using Devel's generate content feature to generate Blog/Forum entries for a site I'm working on and funny enough, I get to have a blog post by an anonymous user or forum topic by an anonymous user.

How can I stop Devel from doing this? I've only given Authenticated Users/ Administrators the permission to create a blog post or forum topic but still it generate for anonymous user. How can correct this?
The Devel module doesn't have options to decide to which users the generated content is assigned, but you can create a custom module to limit the users to which the created content is assigned. You need to:


Implement hook_form_alter() to add the extra form fields necessary to select which users accounts should be used in the form generated by devel_generate_content_form()
Replace the form submission handler with one that generates the content using the user accounts selected in the form


You can use the existing form submission handler (devel_generate_content_form_submit()) as guideline to build your submission handler.

function devel_generate_content_form_submit($form_id, &amp;$form_state) {
  module_load_include('inc', 'devel_generate', 'devel_generate');
  $form_state['values']['node_types'] = array_filter($form_state['values']['node_types']);
  if ($form_state['values']['num_nodes'] &lt;= 50 &amp;&amp; $form_state['values']['max_comments'] &lt;= 10) {
    module_load_include('inc', 'devel_generate');
    devel_generate_content($form_state);
  }
  else {
    module_load_include('inc', 'devel_generate', 'devel_generate_batch');
    devel_generate_batch_content($form_state);
  }
}


Unfortunately, devel_generate_content() doesn't allow to select the user accounts to use as authors of the nodes. This means you need to write all the code yourself. The bright side is that the function that in your module replaces devel_generate_content() is very similar to that function with a single difference: the function to call instead of devel_generate_content_pre_node().

function mymodule_generate_content($form_state) {
  if (!empty($form_state['values']['kill_content'])) {
    devel_generate_content_kill($form_state['values']);
  }

  if (count($form_state['values']['node_types'])) {
    // Generate nodes.
    mymodule_generate_content_pre_node($form_state['values']);
    $start = time();
    for ($i = 1; $i &lt;= $form_state['values']['num_nodes']; $i++) {
      devel_generate_content_add_node($form_state['values']);
      if (function_exists('drush_log') &amp;&amp; $i % drush_get_option('feedback', 1000) == 0) {
        $now = time();
        drush_log(dt('Completed !feedback nodes (!rate nodes/min)', array('!feedback' =&gt; drush_get_option('feedback', 1000), '!rate' =&gt; (drush_get_option('feedback', 1000) * 60) / ($now -$start))), 'ok');
        $start = $now;
      }
    }
  }
}

function mymodule_generate_content_pre_node(&amp;$results) {
  // Get user id.
  $users = mymodule_get_users($results['exclude']);
  $results['users'] = $users;
}

function mymodule_get_users($exclude) {
  $users = array();
  $result = db_query_range("SELECT uid FROM {users} WHERE uid NOT IN :exclude", 0, 50, array(':exclude' =&gt; $exclude);
  foreach ($result as $record) {
    $users[] = $record-&gt;uid;
  }

  return $users;
}


The code I shown assume you add a form field (exclude) that contains the user ID for the user accounts that should not be assigned as authors of the generated nodes.

Probably, you also need to write the equivalent of devel_generate_batch_content(), which is the other function used to generate content, for your module.

Notice that the Devel generate module is used to generate content for developing/testing purposes. It should not be used to generate content for a production server/web site. That is the reason why there aren't too much options for the content to generate.