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.

Capturing user name to use as posted by author

  1. Has anyone ever done this. When a person uses our submission form, as they are a registered user of our site, I'd like to capture their user name and then use that as the posted by author. Any advice?

    http://www.holyhiphopsite.com/submissions-2/

    Posted 13 years ago on Monday November 22, 2010 | Permalink
  2. Gravity Forms already has this an option on the Post Title and Post Body fields. Where you select the default author for the post that is created there is a checkbox to use the user that is logged in, if they are logged in. See this screenshot:

    http://grab.by/7wwl

    Posted 13 years ago on Monday November 22, 2010 | Permalink
  3. I'm sorry Carl I'm not following you. Do I need add that field to my submissions form?

    James

    Posted 13 years ago on Monday November 22, 2010 | Permalink
  4. WordPress knows which user is logged in, and Gravity Forms uses that information to attribute the post to that author. You don't need to add anything to your form. The functionality is built in: you just have to tick the box that is in the screenshot Carl posted.

    Posted 13 years ago on Monday November 22, 2010 | Permalink
  5. Ah, I see, thanks. So to your point of the person being logged in, is there a way to force a person to be logged in in order to use the form?

    James

    Posted 13 years ago on Tuesday November 23, 2010 | Permalink
  6. @trig That wouldn't be something Gravity Forms controls. If you want a form only available to users who are logged in you would have to protect the post or page the form is embedded on. This can be done using the private functionality of WordPress posts or via using a plugin such as the Members plugin to control access to a post or page by user role.

    Posted 13 years ago on Tuesday November 23, 2010 | Permalink
  7. Gil Namur
    Member

    Just so I am clear on this, as I would like to do what Trig mentioned initially. If one of our users (who is NOT logged in) enters a form, and uses the email address associated with their user account, can Gravity forms use that e-mail address to set the post author to that user?

    Posted 13 years ago on Wednesday January 12, 2011 | Permalink
  8. Hi Gil, Gravity Forms will only attribute the post to the submitting user if that user is currently logged in.

    Posted 13 years ago on Wednesday January 12, 2011 | Permalink
  9. If the user is not logged in, you can prevent him from seeing a form by hiding the content with a plugin or procedure designed to hide the content from non-logged in users. That way, they can't submit it if they're not logged in.

    http://codex.wordpress.org/Function_Reference/is_user_logged_in

    http://www.livexp.net/wordpress/using-wordpress-shortcodes-to-show-members-only-content.html

    Posted 13 years ago on Wednesday January 12, 2011 | Permalink