Is it possible to register a user and submit a comment with one form with Wordpress?
Is it possible to do both registering for an account and submit a comment at the same time? I want the user to be able to do this all on one page to ecourage the registration rather than be discouraged about typing something, not realizing they had to be registered and thus having to leave the page.
I think that this could be done by adding register user action to the submit comment action, but not sure how to do it with the prebuilt wordpress add_action or do_action functions. Has anyone tried this, or know of any plug-ins that do this already? I searched but couldn't find anything help开发者_StackOverflow社区ful.
Thanks.
It's surely possible.
You must first familiarize yourself with the API.
Create your user using the WP_CREATE_USER
function:
http://codex.wordpress.org/Function_Reference/wp_create_user
It will return the USER ID
upon successful registration, then you will want to use the WP_INSERT_COMMENT
function to add a comment to a post.
http://codex.wordpress.org/Function_Reference/wp_insert_comment
If your goal is to keep prospective commenters in the same place without sending them off to a registration page you might consider using Fancybox to bring a lightbox-style registration section up over the comments. This isn't quite what you're looking for (i.e. submitting a comment and registration with one click), but it does get both actions to effectively take place in the same page and it can look pretty good too.
精彩评论