Skip to:
Content
Pages
Categories
Search
Top
Bottom

Combined Register + Post

  • Quick Version:

    Is it feasible internally, to have a user post a comment to the forum and register at the same time?

    Detail:

    Something that’s been mentioned already by a regular reader of my blog is that he’d be far less inclined to leave a comment anywhere that he had to register first.

    The BBPress registration process is mind-numbingly simple, but users first have to get over the two-step-hurdle of registering and then leaving their comment.

    So it strikes me that, since the registration details are the same as you have to provide when blog-commenting some middle ground might be beneficial.

    I imagine it working such that when the user submits their comment (topic) their confirmation message is along the lines of:

    Thanks! We’ve sent you an email to confirm your address. Please return here using the link we’ve sent you to make your comment visible.

    From here it becomes a small step to replace the wordpress comment mechanism with bbpress, which is somehting I’d like to do.

Viewing 25 replies - 1 through 25 (of 25 total)

  • Shawn Maddock
    Participant

    @flutedrumr

    I second this one… the “you must login or register to post” is a huge psychological barrier to participating.


    AphelionZ
    Participant

    @aphelionz

    Agreed. Put the fields right there! (this should actually be simple to do with a little template editing) the bbPress dev team might be better to delegate this one…


    Nola1974
    Participant

    @nolageek

    Definitely. I think would be a Really Good Thing(tm), actually. (IMHO)

    I agree. Get someone on it!

    bumping this up so someone can do it :p


    lonemadmax
    Member

    @lonemadmax

    In blogs open without registration I usually put an address @example.com. I’ve also found quite a few people use one time addresses. So if this is going to be done, it should be made clear that the address is not just for gravatars and other such stuff. Also, unconfirmed users should be removed after some time to avoid “usernames starvation”.


    AphelionZ
    Participant

    @aphelionz

    I’d like to see this functionality too!

    1 Year ago latest reply posted.

    I Wonder if this has got any progress in v1.0.2 or if it is easiy doable by templates.

    I was thinking about this and it would be ideal to ask for Name, Email, and Post, when asking for a reply, if it’s a new user, he will be registered as described above, if it matches an existing user, it’ll ask for password before posting.

    It would be a killer feature for me.

    A basic register-then-post would probably be relatively easy using AJAX on the post-form template, without having to touch core files. Modifying registration email behaviour as described earlier in the thread would probably be more difficult. Problem is of course, bbPress support forums are filled with people who want people to write things for them and almost no-one willing to do it.

    That said mind you, I’d give the first part a shot if I could get my head around the kind of form layout you’d need to use.


    Mark
    Member

    @delayedinsanity

    It’s a microwave dinner world… I hate registering on sites that have a mile long page full of demographic information that is an absolute invasion of privacy – I usually move on when I come across those. But when registration consists of username+email+submit… if it ain’t microwaveable, it ain’t worth the effort, I guess. ;)

    I think there should be at least a minimal psychological barrier to prevent thoughtless, spontaneous posts from visitors who might never return anyway.


    Mark
    Member

    @delayedinsanity

    “I think there should be at least a minimal psychological barrier to prevent thoughtless, spontaneous posts from visitors who might never return anyway. “

    Which brings me to my second thought; allowing such a registration system would be an open invitation for a database full of once used member accounts, as well as inviting in the slashdot paradigm. I don’t want anonymous cowards *anywhere* on any site I participate on.

    I think this is a very nice idea, it makes it more interesting for users to want to participate. The easier it is to register + leave a reply, the more interesting.

    Wouldn’t it be easier to enable anonymous posting (there’s a plugin for it somewhere) and add a captcha to that or something? I just had a go at writing a register+post system, but it’s proving hard for me at least not to open up a can of worms bypassing half the checks to prevent non-logged in users from posting.

    Edit: Nevermind, being a bit silly there, newly generated users must have the same capabilities as a standard user anyway.

    I’ve managed to write something to do this so far as registering a new user, logging them in and attempting to add a post, but that always fails. Not even sure why since I can’t see any explicit permission checks within the post function itself. Oh well. Still not tackled hiding user posts either.

    Okay, after much lucky guessing with regards to the user object handling, I have an ALPHA VERSION of a plugin to do this. There’s nothing to stop spambots, this is purely a proof of concept, I’ll try adding a captcha or something later if necessary. Email verification sounds like a royal pain though. Save the files exactly where I’ve said and as ever, make sure you leave no whitespace around the PHP tags. Apart from that, please test it but it’s your own risk if you run it on a production server.

    my-plugins/register-post/load.php:

    <?php
    /*
    Plugin Name: Register & Post
    Description: Allows a user to register and make a post at the same time.
    Author: Kawauso
    Version: Alpha
    */

    // Add the post form
    add_action( 'post_post_form', 'register_post_form' );

    function register_post_form() {

    global $h2, $forum, $topic;

    if( bb_is_user_logged_in() )
    return;

    // Setup the register form

    $profile_info_keys = bb_get_profile_info_keys();

    unset( $profile_info_keys['first_name'], $profile_info_keys['last_name'], $profile_info_keys['display_name'], $profile_info_keys['occ'], $profile_info_keys['from'], $profile_info_keys['user_url'], $profile_info_keys['interest'] );

    $bb_register_error = new WP_Error;

    $user_login_error = $bb_register_error->get_error_message( 'user_login' );

    ?>
    <style type="text/css">p#post-form-forum-container{display:none}</style>
    <form class="postform post-form" id="postform" method="post" action="<?php bb_uri( 'my-plugins/register-post/create.php', null, BB_URI_CONTEXT_FORM_ACTION )?>">
    <h2 class="postform">Register and post?</h2>
    <fieldset>
    <table width="100%">
    <tr class="form-field form-required required<?php if ( $user_login_error ) echo ' form-invalid error'; ?>">
    <th scope="row">
    <label for="user_login"><?php _e('Username'); ?></label>
    <?php if ( $user_login_error ) echo "<em>$user_login_error</em>"; ?>
    </th>
    <td>
    <input name="user_login" type="text" id="user_login" size="30" maxlength="30" value="<?php echo $user_login; ?>" />
    </td>
    </tr>
    <?php

    if ( is_array($profile_info_keys) ) :
    foreach ( $profile_info_keys as $key => $label ) :
    $class = 'form-field';
    if ( $label[0] ) {
    $class .= ' form-required required';
    }
    if ( $profile_info_key_error = $bb_register_error->get_error_message( $key ) )
    $class .= ' form-invalid error';

    ?>

    <tr class="<?php echo $class?>">
    <th scope="row">
    <label for="<?php echo $key?>"><?php echo $label[1]?></label>
    <?php if ( $profile_info_key_error ) echo "<em>$profile_info_key_error</em>"; ?>
    </th>
    <td>
    <input name="<?php echo $key?>" type="text" id="<?php echo $key?>" size="30" maxlength="140" value="<?php echo $$key?>" />
    </td>
    </tr>

    <?php

    endforeach; // profile_info_keys
    endif; // profile_info_keys

    ?>
    </table>

    <br />

    <?php
    bb_load_template( 'post-form.php', array('h2' => $h2) );
    bb_nonce_field( bb_is_topic() ? 'create-post_' . $topic->topic_id : 'create-topic' );
    if ( bb_is_forum() ) {
    echo '<input type="hidden" name="forum_id" value="' . $forum->forum_id . '" />' . "n";
    } elseif ( bb_is_topic() ) {
    echo '<input type="hidden" name="topic_id" value="' . $topic->topic_id . '" />' . "n";
    }
    echo "n</fieldset>n</form>n";

    }

    my-plugins/register-post/create.php:

    <?php

    require_once('../../bb-load.php');

    $profile_info_keys = bb_get_profile_info_keys();

    unset( $profile_info_keys['first_name'], $profile_info_keys['last_name'], $profile_info_keys['display_name'], $profile_info_keys['occ'], $profile_info_keys['from'], $profile_info_keys['user_url'], $profile_info_keys['interest'] );

    $user_login = '';
    $user_safe = true;

    $bb_register_error = new WP_Error;

    if ( $_POST && 'post' == strtolower($_SERVER['REQUEST_METHOD']) ) {
    $_POST = stripslashes_deep( $_POST );
    $_POST['user_login'] = trim( $_POST['user_login'] );
    $user_login = sanitize_user( $_POST['user_login'], true );
    if ( $user_login !== $_POST['user_login'] ) {
    $bad_input = true;
    if ( $user_login )
    $bb_register_error->add( 'user_login', sprintf( __( "%s is an invalid username. How's this one? <strong>%s</strong>" ), esc_html( $_POST['user_login'] ), $user_login ) );
    else
    $bb_register_error->add( 'user_login', sprintf( __( '%s is an invalid username.' ), esc_html( $_POST['user_login'] ) ) );
    }

    foreach ( $profile_info_keys as $key => $label ) {
    if ( is_string($$key) )
    $$key = esc_attr( $$key );
    elseif ( is_null($$key) )
    $$key = esc_attr( $_POST[$key] );

    if ( !$$key && $label[0] == 1 ) {
    $bad_input = true;
    $$key = false;
    $bb_register_error->add( $key, sprintf( __( '%s is required' ), $label[1] ) );
    }
    }

    if ( !$bad_input ) {

    // Invoke non-user post checks here
    if ( !$post_content = trim($_POST['post_content']) )
    bb_die(__('You need to actually submit some content!'));

    if ( isset($_POST['topic']) && $forum_id = (int) $_POST['forum_id'] ) {

    $topic = trim( $_POST['topic'] );

    if ('' == $topic)
    bb_die(__('Please enter a topic title'));

    } elseif ( isset($_POST['topic_id'] ) ) {
    $topic_id = (int) $_POST['topic_id'];
    bb_check_admin_referer( 'create-post_' . $topic_id );
    }

    if ( !topic_is_open( $topic_id ) )
    bb_die(__('This topic has been closed'));

    // Invoke registration
    $user_id = bb_new_user( $user_login, $_POST['user_email'], null );
    if ( is_wp_error( $user_id ) ) { // Error creating user

    foreach ( $user_id->get_error_codes() as $code )
    $bb_register_error->add( $code, $user_id->get_error_message( $code ) );

    if ( $bb_register_error->get_error_message( 'user_login' ) )
    $user_safe = false;

    } elseif ( $user_id ) { // Registration success

    foreach( $profile_info_keys as $key => $label )
    if ( strpos($key, 'user_') !== 0 && $$key !== '' )
    bb_update_usermeta( $user_id, $key, $$key );

    do_action('register_user', $user_id);

    // Create the current user object

    $wp_auth_object->set_current_user( $user_id );

    $bb_current_user = $wp_auth_object->current;

    // Do last minute post/topic checks
    if ( !empty($topic) && $forum_id = (int) $_POST['forum_id'] ) {

    if ( !bb_current_user_can('write_posts') )
    bb_die(__('You are not allowed to post. Are you logged in?'));

    if ( !bb_current_user_can( 'write_topic', $forum_id ) )
    bb_die(__('You are not allowed to write new topics.'));

    if ( !bb_current_user_can( 'write_topic', $forum_id ) )
    bb_die(__('You are not allowed to write new topics in this forum.'));

    bb_check_admin_referer( 'create-topic' );
    $topic_id = bb_new_topic( $topic, $forum_id, $tags );

    }

    if ( !bb_current_user_can( 'write_post', $topic_id ) )
    bb_die(__('You are not allowed to post in this topic.'));

    // Create the new post
    $post_id = bb_new_post( $topic_id, $_POST['post_content'] );

    $tags = trim( $_POST['tags'] );
    bb_add_topic_tags( $topic_id, $tags );

    $link = get_post_link( $post_id );

    $topic = get_topic( $topic_id, false );

    if ( $topic->topic_posts )
    $link = add_query_arg( 'replies', $topic->topic_posts, $link );

    do_action( 'bb-post.php', $post_id );

    if ( $post_id )
    wp_redirect( $link );
    else
    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    exit;
    }
    }
    }

    // If you've reached this point, there must have been an error

    $user_login_error = $bb_register_error->get_error_message( 'user_login' );

    if( empty( $user_login_error ) ) // For some reason, error strings are not always available (i.e. for invalid emails)
    $user_login_error = __( 'Something went wrong! Check what you entered and try again.' );

    bb_die( $user_login_error );

    Any updates on this plugin.

    I would love to see a plugin where after a non-logged in user attempts to submit a post, it then prompts them to login or create an account.

    Functionally, it would work exactly how StreetEasy’s forum system works.

    Linked below is an example:

    http://www.streeteasy.com/nyc/talk/discussion/15563-weird-floor-plans

    Note how it displays the TEXTAREA prompting the user to contribute to the discussion and only once you click “submit” it checks to see if you’re logged in. If not, it prompts you to login or create the account.

    Since there’s been no other interest and feedback on this plugin, I don’t think I’d be too inclined to try and do that as functionally this is fine. Someone else is quite welcome to use how I modified things as an example for implementing that though, it’d probably be quite easy if you get your head around how things work.

    I’ve been looking the code for a while, I’m not that familiar with bbPress yet, but i’d really like this feature so I’ll keep an eye on this.

    anabelle: The code that I’ve posted is fully working as a proof of concept, so you could use it. I’m not sure if this would ever be implemented into the core code though. I’ll look into re-doing it with an interstatial page at a later point if I have the time.

    Sure, and i’ll definitely use it. Im just a little scared about support or having to fix things that are beyond my reach.

    So, as much as i Will test it. I don’t think im using it in production enivonment yet.

    But, my concept of a forum, the way I am conceiving it, designin it, and targeting it, REQUIRES this feature. I won’t use it right now but I’m sure the lack of it will almost fully stop the growth of the site.

    Simple as is, mi site “¿Cómo diablos.. ?” is targeted to solve basic questions to tech newbies in spanish, you can imagine there are a LOT of people, and grownups how are just getting to know a computer. And the process of registering, in a separate page, activating through email, and then asking some really basic question, it just really doesn’t work.

    What we’ve been using until now is a WordPress site, with reply to coment mail notification enabled. So they just ask, and get the answer to their mails. It’s working ok. But we really think the right way of doing it is using a forum. Auto-creating an account when the user signs up could be incredibly useful for getting recurent visitors and building local support communities in common language.

    Sorry for writing so much in such a bad english :P hope you understand.

    If your concept of the site depends on this plugin, you may want to consider hiring a developer (like Kawauso!) to build and test it for you…

    Regarding waiting for the password over email – you can address that with this plugin! I use it on all my sites and can vouch for it:

    https://bbpress.org/plugins/topic/instant-password/

    This may also simplify the registration process… I haven’t used this one yet though:

    https://bbpress.org/plugins/topic/openid/

    Good luck!

    I bypassed the activation email requirement for the first post (the one made with the plugin), so the post is added immediately and the registration can be taken of later. Other option is to use an anonymous posting plugin. I’ll be around to do support possibly, and that’s the case with most plugins for bbPress, try looking at how many are abandoned… otherwise, pay someone for support, that’s the only real way to ensure it’s there.

    That would be great, Im sure i don’t have the best way to do it, im sure working together we can find the best way of achieving it.

    I’d love to pay, and I will. You must consider nonetheless I live and work in colombia. My current salary is les than $5 an hour. And I can’t even pay half that :( BUT! Im happy to give “donations” if the developer is ok. How much do you charge?

    I’ve thought about anonymous, but that isn’t the idea. If an account can be created, why not?

    I will surely use instant pasword! thanks for that!

    That gives me even more clear ideas about this.

    The reply form in a topic, if a user is logged out. Should include login, password, and reply.

    If the account exists, login and post. If it doesn’t exist; ask for email, createaccount, login and post.

    A special message could be shown. Your reply has been posted! And an account has been created for you. Thanks for joining our community.

    What do you think about it?

    I’m afraid I don’t take on paid work, since I simply can’t guarantee the time needed to write code on demand, ensure it’s to a standard expected of paid work and to be honest, I don’t need the money anyway.

    As I said, I’d be more than happy for someone else to use my code as reference on how to implement such a feature, since it’s pretty much just butchered up parts of core bbPress code, but as it stands I simply don’t have the time to work on the plugin and guarantee it’s to a production standard, paid or not.

    As to the requesting login details later part, I think that was requested before, and I did look into doing it, but because of the way bbPress is structured internally, you have to bypass so many checks against the referring page and carry over the post data to be passed later on. Do-able yes, but not really a 5 minute job, since as far as I know you’d still need to re-do the post function as I did previously.

    It’s nice to know there’s still interest in this though, and I’ll look into trying to implement it more cleanly later on with requested features. Having pulled and learnt the login and post system once, it should be easier a second time. Really, really wish we had a bbPress codex, so it could be documented more.

Viewing 25 replies - 1 through 25 (of 25 total)
  • You must be logged in to reply to this topic.
Skip to toolbar