Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/21/2024 06:37:13 AM (12 months ago)
Author:
imath
Message:

Stop creating a user when a signup is performed on regular WP configs

Since version 2.0, we are using the $wpdb->signups table to manage pending accounts. We kept on creating a user as well as a user meta to store the activation key for regular WP configs.

This user creation step is now deprecated and by default no user will be created on any WordPress config once a user signs up. In next BP major version we'll fully remove the code but until then you can always use the bp_signups_create_user filter (returning true) or define the deprecated constant BP_SIGNUPS_SKIP_USER_CREATION to false to carry on creating the user on regular WP configs.

This move allows us to fix a 9 years old ticket and is more consistent: signups are becoming users only when they validate their account.

Props johnjamesjacoby, DJPaul, espellcaste

Fixes #6123
Closes https://github.com/buddypress/buddypress/pull/271

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r13743 r13798  
    18591859        $user_email     = sanitize_email( $user_email );
    18601860        $activation_key = wp_generate_password( 32, false );
     1861        $create_user    = false;
     1862
     1863        // @deprecated.
     1864        if ( defined( 'BP_SIGNUPS_SKIP_USER_CREATION' ) ) {
     1865            _doing_it_wrong( 'BP_SIGNUPS_SKIP_USER_CREATION', esc_html__( 'the `BP_SIGNUPS_SKIP_USER_CREATION` constant is deprecated as skipping user creation is now the default behavior.', 'buddypress' ), 'BuddyPress 14.0.0' );
     1866
     1867            // Creating a user is the opposite of skipping user creation.
     1868            $create_user = ! BP_SIGNUPS_SKIP_USER_CREATION;
     1869        }
    18611870
    18621871        /**
    1863          * WordPress's default behavior is to create user accounts
    1864          * immediately at registration time. BuddyPress uses a system
    1865          * borrowed from WordPress Multisite, where signups are stored
    1866          * separately and accounts are only created at the time of
    1867          * activation. For backward compatibility with plugins that may
    1868          * be anticipating WP's default behavior, BP silently creates
    1869          * accounts for registrations (though it does not use them). If
    1870          * you know that you are not running any plugins dependent on
    1871          * these pending accounts, you may want to save a little DB
    1872          * clutter by defining setting the BP_SIGNUPS_SKIP_USER_CREATION
    1873          * to true in your wp-config.php file.
     1872         * Filter here to keep creating a user when a registration is performed on regular WordPress configs.
     1873         *
     1874         * @since 14.0.0
     1875         * @todo Fully deprecate in 15.0.0
     1876         *
     1877         * @param boolean $create_user True to carry on creating a user when a registration is performed.
     1878         *                             False otherwise.
    18741879         */
    1875         if ( ! defined( 'BP_SIGNUPS_SKIP_USER_CREATION' ) || ! BP_SIGNUPS_SKIP_USER_CREATION ) {
     1880        if ( apply_filters( 'bp_signups_create_user', $create_user ) ) {
    18761881            $user_id = BP_Signup::add_backcompat( $user_login, $user_password, $user_email, $usermeta );
    18771882
     
    20182023            $user_id = wp_create_user( $signup->user_login, $password, $signup->user_email );
    20192024
    2020         // Otherwise, update the existing user's status.
     2025            /*
     2026             * @todo Remove this `elseif` statement in version 15.0.0.
     2027             *
     2028             * Since 2.0.0 BuddyPress is using the $wpdb->signups table even in regular WordPress configs.
     2029             * In 14.0.0, we are deprecating the `BP_SIGNUPS_SKIP_USER_CREATION` as well as creating a user
     2030             * each time a registration is performed.
     2031             */
    20212032        } elseif ( $key === bp_get_user_meta( $user_id, 'activation_key', true ) || $key === wp_hash( $user_id ) ) {
    20222033
Note: See TracChangeset for help on using the changeset viewer.