WordPress.org

Ready to get started?Download WordPress

Forums

BuddyPress Registration Options
Gravity Forms Registration Add On (13 posts)

  1. hughshields
    Member
    Posted 9 months ago #

    I have built a custom registration form with Gravity Forms Registration Add On and am trying to figure out how to make BP Registration Options work with this custom form. Gravity Forms has options to verify via an email link but this approves the user upon activation of the link and does not allow the BP Registration Options workflow to work.
    Does anyone have experience making BP Registration Options work with a custom form?
    Thanks!

    http://wordpress.org/plugins/bp-registration-options/

  2. Michael Beckwith
    Member
    Plugin Author

    Posted 9 months ago #

    on the bp_core_activate_account hook, if the "key" $_GET parameter, which I believe comes from the WP activation link, is set we update the user_status value in the DB to "69". Don't ask me why that number, I wasn't part of the original development :D We also set a "hide_sitewide" field to 1 aka true, in the bp_activity table.

    The moment you approve the user, the user_status is set to 0, an the hide_sitewide is set to 0 aka false.

    //Hide user created by new user on activation.
    $sql = 'UPDATE ' . $wpdb->base_prefix . 'users SET user_status = 69 WHERE ID = %d';
    $wpdb->query( $wpdb->prepare( $sql, $user_id ) );
    
    //Hide activity created by new user
    $sql = 'UPDATE ' . $wpdb->base_prefix . 'bp_activity SET hide_sitewide = 1 WHERE user_id = %d';
    $wpdb->query( $wpdb->prepare( $sql, $user_id ) );
  3. hughshields
    Member
    Posted 9 months ago #

    Thanks for the information. I appreciate it.
    When I register a new user using the Buddypress Registration process the BP Registration Options approval process works perfectly. When I try to register using the custom Gravity forms registration the new user is activated automatically. I did notice that the mails sent are slightly different:

    Buddypress Registration Activation link:
    http://uberon.net/?page=gf_activation&key=f12d8d682c1d8cde

    Gravity Forms Registration Activation link:
    http://uberon.net/activate/?key=2714b634b0c01a2f136c92f17ed5392e

    I haven't been able to come up with a fix yet. Still turning up clues.
    Thanks again for your input.

  4. Michael Beckwith
    Member
    Plugin Author

    Posted 9 months ago #

    It may not be a bad idea for WebDevStudios to offer GravityForms integration for our plugin here. It's something that we'd have to look into and do up, and I can't make any guarantees.

    I think you got your links reversed, but I get the idea anyway :D

    Hopefully you can get this working in your own way though. Let me know if you have any other questions or need more info.

  5. hughshields
    Member
    Posted 9 months ago #

    You are correct. I reversed the links. The one with "gf" is obviously Gravity Forms. Sorry about that!

    I think I found a solution which I will pass along in case someone else has the same issue. I turned off all Additional Options in Gravity Forms Registration Add On so that no verification email is sent by Gravity forms. I then added the following to the functions.php in my child theme:

    /**
     * GF Registration Process Set User to Not Authenticated to enable verification
    */
    
    function gf_bp_profile_activation( $user_id ) {
        global $wpdb;
    
         //Update the user status to '69' which we will use as 'not activated' (0 = active, 1 = spam, 69 = not active)
        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 69 WHERE ID = %d", $user_id ) );
    
        if ( !is_multisite() ) {
            $activation_key = wp_hash( $user_id );
            $userdata = get_userdata($user_id);
            update_user_meta( $user_id, 'activation_key', $activation_key );
    
            if ( apply_filters( 'bp_core_signup_send_activation_key', true ) ) {
                bp_core_signup_send_validation_email( $user_id, $userdata->user_email, $activation_key );
            }
        }
    }
    
    add_action( 'gform_user_registered', 'gf_bp_profile_activation', 11 );
  6. hughshields
    Member
    Posted 9 months ago #

    If you are thinking about integrating BP Registration Options with Gravity Forms Registration Add On then a list of developer hooks and filters for the GF Registration Add On can be found at:

    http://www.gravityhelp.com/documentation/page/User_Registration_Add-on_Developer_Docs

    The one that looks particularly interesting is:
    gform_user_registration_add_option_group
    Used to add a group of options to the "Additional Options" section of the User Registration Feed. Useful when you want to add one or two options without requiring a whole section.

    You could potentially add a BP Registration Options choice to the Gravity Forms Additional Options menu.

  7. hughshields
    Member
    Posted 9 months ago #

    On closer look the above code has a few flaws. Firstly the user is showing up immediately in the activity feed as registered, although the member profile does not display. Also when I approve a new member the member count on the Members page does not increase for some reason.
    The issue with the activity feed I believe is because I did not set hide_sitewide to 1 in the above function. But I am not sure why the member count is not working. Any ideas?

  8. Michael Beckwith
    Member
    Plugin Author

    Posted 9 months ago #

    I would assume the other parts of what the code does is why the member count doesn't increment. However, if this is for users you approved and it doesn't increment, then it's something else that I'd need to check on.

  9. hughshields
    Member
    Posted 9 months ago #

    Hi Michael,
    I tested out adding new members using the default buddypress registration with BP Registration Options and the member number doesn't work there either, so it appears to be a BP Registration Options plugin issue and is not related to Gravity Forms.
    Have you run into problems with the member number not incrementing before, and if so any known fix.
    Thanks!

  10. Michael Beckwith
    Member
    Plugin Author

    Posted 9 months ago #

    I hadn't noticed it myself, and I can't recall anyone having reported the issue either, so I don't have any ideas on fixing it at the moment. I'll definitely file an issue for myself for later so I can check it out and possibly solve.

  11. hughshields
    Member
    Posted 9 months ago #

    It looks like when a new user logs in for the first time in Buddypress the total member cache is deleted and then recounted.
    I assume that BP Registration Options suppresses this, but at approval should then should recount the members. I poked around the plugin but couldn't find the code for this.

  12. Michael Beckwith
    Member
    Plugin Author

    Posted 9 months ago #

    I'll have to look into tinkering with that cache then. Thanks for pointing that much out :D

  13. Michael Beckwith
    Member
    Plugin Author

    Posted 3 months ago #

    hughshields, You'll want to test your modifications with http://wordpress.org/support/topic/420-beta?replies=1. I definitely redid a lot of the underlying code, including how it's marked that a user is still in moderation. Primarily I moved to user meta instead of user status.

    Let me know if any questions or issues come up with this. Hoping the code and whatnot is better and more solid with restriction.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.