[wp-hackers] "commenter" user role

Otto otto at ottodestruct.com
Wed Mar 10 19:52:25 UTC 2010

On Wed, Mar 10, 2010 at 1:27 PM, Jeremy Clarke <jer at simianuprising.com> wrote:
> If you think that the current system for doing this is clunky then you
> should work on improvements to the current system. I'd love it there
> was a built-in way to set up your comment form in such a way that it
> basically signs people up for accounts by default, without seeing the
> admin. That might be plugin territory or not, but there's no reason to
> believe that changing the DB structure will improve it inherently.

It's actually not that hard to do as a plugin.

add_action to pre_comment_on_post. That function looks at the
submitted email value, then calls get_user_by_email to see if the user
has already registered or not. If not, it can add him using
wp_insert_user and the submitted values. Then it will need to call
wp_set_current_user() to make the user "logged in". After that, the
normal comment handling code will automatically fill in the user_ID

Should be no more than, say, 15-20 lines of code.


More information about the wp-hackers mailing list