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?
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?
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:
I'm sorry Carl I'm not following you. Do I need add that field to my submissions form?
James
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.
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
@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.
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?
Hi Gil, Gravity Forms will only attribute the post to the submitting user if that user is currently logged in.
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