PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

File signed in user as author of submitted form which files to custom post type

  1. Hello,

    My form files to a custom post type in a Pending status. Only signed in users can submit entries with the form.

    I'm having a problem getting the user that's signed in to be associated to the Pending post that's created. Right now it's always defaulting to me.

    I've tried using a hidden field with the default value set to User Login. In the email that's generated I can see the correct user's login name defined, but the post is not associated to the user.

    I've also tried dynamically populating the field with:

    add_filter('gform_field_value_submitted_by_user', 'populate_submitted_by_user');
    function populate_submitted_by_user($value){
     global $current_user;
     get_currentuserinfo();
     return $current_user -> user_login;
    }

    Again, the email that's generated displays the correct user login name but the post is not associated to the user.

    Users are set as contributors when registering on the site.

    Posted 12 years ago on Tuesday January 3, 2012 | Permalink
  2. On your post body or post title field, have you checked the box "Use logged in user as author"?

    http://minus.com/mJxnjvfbs

    That should take care of it without any code in your functions.php.

    Posted 12 years ago on Tuesday January 3, 2012 | Permalink
  3. Thanks Chris! I forgot that was an option when I first defined the form to file to a custom post type!

    Posted 12 years ago on Tuesday January 3, 2012 | Permalink
  4. There you go. Glad you found out how to do that. Thanks for the update.

    Posted 12 years ago on Wednesday January 4, 2012 | Permalink

This topic has been resolved and has been closed to new replies.