• Resolved antonv

    (@antonv)


    First of all thank you for a great plugin that works and is easy to understand, especially after viewing your excellent youtube tutorials.

    Background: My application is on a site with registered users who would be allowed to upload posts with a PDF attachment. Non registered users will not be served the contact form.

    In the contact form I use the field [text User default:user_login] which could also have a hidden attribute and I link this field in the Form to Post tab to Post Author. However, this information is not included in the post meta. The data base shows post_author = 0 in the wp_posts database instead of the user’s ID as found in the wp_users database

    It would be great if you could search the database wp_users with the post author passed to your plugin and insert the user’s ID into post_author field of wp_posts when creating the post.

    thanks and regards
    Anton

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter antonv

    (@antonv)

    solved the problem, added following to the theme’s function.php

       add_action('cf7_2_post_form_submitted_to_post', 'new_post_mapped',10,4);
    
      function new_post_mapped($post_id, $cf7_form_data, $cf7form_key, $submitted_files){
         $current_user = wp_get_current_user();
         $author_id = $current_user->ID;
         $arg = array(
            'ID' => $post_id,
            'post_author' => $author_id,
            );
        wp_update_post( $arg );
      }
    Thread Starter antonv

    (@antonv)

    housekeeping: marking as resolved

    Plugin Author Aurovrata Venet

    (@aurovrata)

    However, this information is not included in the post meta. The data base shows post_author = 0 in the wp_posts database instead of the user’s ID as found in the wp_users database

    that’s odd indeed. I will look into this, because this is what I would also expect to work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Author not working as expected’ is closed to new replies.