WordPress.org

Ready to get started?Download WordPress

Forums

BuddyPress Pending Activations
[resolved] $wpdb->prepare error (9 posts)

  1. dcavins
    Member
    Posted 1 year ago #

    Hi Rich-

    With 3.5, prepare expects an additional argument, so it issues a warning for line 18 of function etivite_bp_pending_activations_users_count(). It doesn't look like you need prepare anyway (since the query isn't using any variables), so I've updated the statement to

    $count = $wpdb->get_var( "SELECT COUNT(u.ID) FROM $wpdb->usermeta m1, $wpdb->users u WHERE u.ID = m1.user_id AND u.user_status = 2 AND m1.meta_key = 'activation_key' ORDER BY u.user_registered ASC" );

    It works fine for me on two test installations.

    -David

    http://wordpress.org/extend/plugins/buddypress-pending-activations/

  2. Norm
    Member
    Posted 1 year ago #

    David,

    I'm trying to migrate users into a buddypress environment and need to activate all the existing users in bp.

    This plugin would be very helpful but I'm not sure where I would take your code and apply it to the existing plugin. Could you post the file you modified somewhere?

    Thanks.

  3. dcavins
    Member
    Posted 1 year ago #

    Hi Norm-

    You can make the necessary change pretty easily. Within the plugin folder buddypress-pending-activations, open the file bp-pending-activations.php and find this line (it's not a long file):

    $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(u.ID) FROM $wpdb->usermeta m1, $wpdb->users u WHERE u.ID = m1.user_id AND u.user_status = 2 AND m1.meta_key = 'activation_key' ORDER BY u.user_registered ASC" ) );

    Replace it with my correction in the post above and you should be set. (You could actually do this via WordPress' built-in plugin editor, too.) Let me know if you could use more advice.

  4. Norm
    Member
    Posted 1 year ago #

    Thanks that seemed to do half the trick. I'm getting this error on the plugin admin page. It's showing no users as pending but that is clearly not the case.

    Any thoughts?

    Warning: Missing argument 2 for wpdb::prepare(), called in .../wp-content/plugins/buddypress-pending-activations/admin/bp-pending-activations-admin.php on line 6 and defined in .../wp-includes/wp-db.php on line 990

  5. dcavins
    Member
    Posted 1 year ago #

    Yep, you're right, there are several more prepares in the admin interface code. (But they don't actually prevent the plugin from working.)

    Can you explain your problem a little further? Are you transitioning to BuddyPress from WordPress (and your users already exist) or are you bulk adding users and wanting to activate their accounts?

    Do you have access to your database? The reason I ask is that the BP Pending Activations plugin will only find users that have a user_status of 2 (unverified, basically) AND an activation key associated with their account in the wp_usermeta table. (It only finds users that signed up using the BP system.) If you do have access to your db, search the usermeta table for the meta_key with the value of activation_key.

  6. Norm
    Member
    Posted 1 year ago #

    I'm moving users from Joomla to WordPress. I do have access to the database.

    I've been able to move the users into wordpress without buddypress where they can login after going through the password reset process. When I brought buddypress into the mix I could still go through the password reset process but then unable to login because the account isn't activated.

    The user status for the imported users is 2 in the wp_user table. There isn't a an activation_key associated with those useres in the wp_usermeta table. Just wp_user_level and wp_capabilities.

    When I look a the Pending Activation plugin admin I see zero users in the list. I assumed it is because I'm still seeing that error message and it can't properly call the users.

    What I gather from what you are saying is that I need to add a row for each user to the wp_usermeta table with the right data that implies activated user.

  7. dcavins
    Member
    Posted 1 year ago #

    Hi Norm-

    If you're comfortable making changes in the db, make a backup of the wp_users table, than change each user's user_status from 2 to 0. And they will be seen as "activated" users, and allowed to log in.

    The normal BuddyPress registration process is like this:

    1. User signs up via BP form. (At this point, the user is created in the wp_users table and given the user_status of 2. BP also creates the activation_key entry in the usermeta db.)
    2. WP/BP sends the user an e-mail with the activation key in it.
    3. User clicks on the link in the e-mail, telling WP/BP that the e-mail address was legitimate. (BP sets the user_status to 0 in the db and deletes the activation_key entry in the usermeta db.)

    I wouldn't worry about the plugin at this point. It's meant to help activate users who signed up in the "normal" BuddyPress way, but didn't respond to the verification e-mail (usually because it got marked as spam).

  8. Norm
    Member
    Posted 1 year ago #

    That is the solution!

    Changing the user_status to "0" in wp_users did the trick.

    Thanks for your help. I can see how the plugin will be helpful moving forward and keeping an eye on inactive registrations.

  9. baldgoat
    Member
    Plugin Author

    Posted 1 year ago #

    This should be fixed in the latest release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags