Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/27/2018 04:39:38 PM (22 months ago)
Author:
r-a-y
Message:

Activation: Add default WordPress role for new signups.

Props r-a-y, needle, espellcaste, DJPaul, boonebgorges.

Fixes #7565.

File:
1 edited

Legend:

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

    r11818 r11829  
    18581858            bp_delete_user_meta( $user_id, 'activation_key' );
    18591859
    1860             $member = get_userdata( $user_id );
    1861             $member->set_role( get_option('default_role') );
    1862 
    18631860            $user_already_created = true;
    18641861
     
    19831980
    19841981/**
     1982 * Add default WordPress role for new signups on the BP root blog.
     1983 *
     1984 * @since 3.0.0
     1985 *
     1986 * @param int $user_id The user ID to add the default role for.
     1987 */
     1988function bp_members_add_role_after_activation( $user_id ) {
     1989    // Get default role to add.
     1990    $role = bp_get_option( 'default_role' );
     1991
     1992    // Multisite.
     1993    if ( is_multisite() && ! is_user_member_of_blog( $user_id, bp_get_root_blog_id() ) ) {
     1994        add_user_to_blog( bp_get_root_blog_id(), $user_id, $role );
     1995
     1996    // Single-site.
     1997    } elseif ( ! is_multisite() ) {
     1998        $member = get_userdata( $user_id );
     1999        $member->set_role( $role );
     2000    }
     2001}
     2002add_action( 'bp_core_activated_user', 'bp_members_add_role_after_activation', 1 );
     2003
     2004/**
    19852005 * Migrate signups from pre-2.0 configuration to wp_signups.
    19862006 *
Note: See TracChangeset for help on using the changeset viewer.