Quantcast
Viewing all articles
Browse latest Browse all 20145

Reply To: [Assigned] CRED – Question about author field

Dear Deva,

In my testing, I used a CRED form with ID 12.
You will have to replace the 12 with the id of your CRED form.

You will also need to replace 44 with the id of your anonymous user (you have to create it).

This code can go in functions.php in your theme.

add_action(‘cred_save_data’, ’my_save_data_action’,10,2);
function my_save_data_action($post_id, $form_data) {
  // if a specific form
  if ($form_data[‘id’]==12) {
     
      if ( !is_user_logged_in() ) {
          wp_insert_post( array(
              'ID' => $post_id,
              'post_author' => 44   // anonymous
          ) );
      }

  }
}

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad


Viewing all articles
Browse latest Browse all 20145

Trending Articles