Ticket #5977: 5977.02.patch
File 5977.02.patch, 6.2 KB (added by , 10 years ago) |
---|
-
src/bp-core/bp-core-functions.php
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php index 5b93f9c..ae7fd2e 100644
function bp_is_network_activated() { 1528 1528 return (bool) apply_filters( 'bp_is_network_activated', $retval ); 1529 1529 } 1530 1530 1531 /** 1532 * Check wether BuddyPress is activated on the main site 1533 * 1534 * @since BuddyPress (?) 1535 * 1536 * @param int $site_id the site ID to check. 1537 * @return bool true if not multisite or if multisite and BuddyPress 1538 * root blog id is the same than WordPress network main site, 1539 * false otherwise. 1540 */ 1541 function bp_is_main_site_for_network( $site_id = 0 ) { 1542 if ( empty( $site_id ) ) { 1543 $site_id = bp_get_root_blog_id(); 1544 } 1545 1546 return (bool) is_main_site( $site_id ); 1547 } 1548 1531 1549 /** Global Manipulators *******************************************************/ 1532 1550 1533 1551 /** … … function bp_core_get_suggestions( $args ) { 2034 2052 } 2035 2053 2036 2054 return apply_filters( 'bp_core_get_suggestions', $retval, $args ); 2037 } 2038 No newline at end of file 2055 } -
src/bp-members/bp-members-admin.php
diff --git src/bp-members/bp-members-admin.php src/bp-members/bp-members-admin.php index 8ca63b7..ad871cf 100644
class BP_Members_Admin { 410 410 ); 411 411 412 412 // Only show sign-ups where they belong 413 if ( ! is_multisite() || is_network_admin() ) {413 if ( ! is_multisite() || ( is_network_admin() && ! $this->subsite_activated ) || ( $this->subsite_activated && ! is_network_admin() ) ) { 414 414 415 415 // Manage signups 416 416 $hooks['signups'] = $this->signups_page = add_users_page( -
src/bp-members/bp-members-functions.php
diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php index 1fba30e..fc378c6 100644
function bp_core_validate_blog_signup( $blog_url, $blog_title ) { 1535 1535 } 1536 1536 1537 1537 /** 1538 * Specific config : BuddyPress is activated on main site but is not network 1539 * activated. In this case, we need to add specific usermeta so that the user 1540 * will also be a member of the main site. 1541 * 1542 * Once the signup is activated, WordPress will add the user to the blog if 1543 * he's not signing up with a blog, else BuddyPress will add the user to main 1544 * site. 1545 * 1546 * @since BuddyPress (?) 1547 * 1548 * @param array $usermeta the signup meta informations 1549 * @return array the signup meta unchanged or with specific ones if needed 1550 */ 1551 function bp_core_get_blog_signup_meta( $usermeta = array() ) { 1552 if ( ! bp_is_network_activated() && bp_is_main_site_for_network() ) { 1553 $usermeta = array_merge( $usermeta, array( 1554 'add_to_blog' => bp_get_root_blog_id(), 1555 'new_role' => bp_get_option( 'default_role', 'subscriber' ), 1556 ) ); 1557 } 1558 1559 return (array) apply_filters( 'bp_core_get_blog_signup_meta', $usermeta ); 1560 } 1561 1562 /** 1538 1563 * Process data submitted at user registration and convert to a signup object. 1539 1564 * 1540 1565 * @todo There appears to be a bug in the return value on success. … … function bp_core_signup_user( $user_login, $user_password, $user_email, $usermet 1552 1577 // We need to cast $user_id to pass to the filters 1553 1578 $user_id = false; 1554 1579 1580 // Specific config 1581 $usermeta = bp_core_get_blog_signup_meta( $usermeta ); 1582 1555 1583 // Multisite installs have their own install procedure 1556 1584 if ( is_multisite() ) { 1557 1585 wpmu_signup_user( $user_login, $user_email, $usermeta ); … … function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, 1622 1650 return false; 1623 1651 } 1624 1652 1653 // Specific config 1654 $usermeta = bp_core_get_blog_signup_meta( $usermeta ); 1655 1625 1656 return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) ); 1626 1657 } 1627 1658 1628 1659 /** 1660 * Make sure a user who registered with a blog has a role on the main site 1661 * if BuddyPress is activated on it but not network activated 1662 * 1663 * @since BuddyPress (?) 1664 * 1665 * @param int $blog_id the blog ID the user registered 1666 * @param int $user_id the user ID 1667 * @param string $password 1668 * @param string $signup_title 1669 * @param array $meta the signup meta we need. 1670 */ 1671 function bp_core_maybe_activate_user_on_root_blog( $blog_id = 0, $user_id = 0, $password = '', $signup_title = '', $meta = array() ) { 1672 // Do nothing for regular multisite config 1673 if ( bp_is_network_activated() ) { 1674 return; 1675 } 1676 1677 // Bail if we do not have needed signup metas 1678 if ( empty( $meta['add_to_blog'] ) || empty( $meta['new_role'] ) || empty( $user_id ) ) { 1679 return; 1680 } 1681 1682 /** 1683 * Handle the specific config : BuddyPress is not network activated 1684 * but is activated on the main site. 1685 */ 1686 if ( bp_is_main_site_for_network() ) { 1687 $blog_id = absint( $meta[ 'add_to_blog' ] ); 1688 1689 // Bail if we don't get BuddyPress root blog 1690 if ( bp_get_root_blog_id() != $blog_id ) { 1691 return; 1692 } 1693 1694 $role = sanitize_text_field( $meta[ 'new_role' ] ); 1695 1696 // Finally add user to blog without setting it as primary 1697 add_user_to_blog( $blog_id, $user_id, $role ); 1698 } 1699 } 1700 add_action( 'wpmu_activate_blog', 'bp_core_maybe_activate_user_on_root_blog', 10, 5 ); 1701 1702 /** 1629 1703 * Activate a signup, as identified by an activation key. 1630 1704 * 1631 1705 * @param string $key Activation key. … … function bp_core_activate_signup( $key ) { 1636 1710 1637 1711 $user = false; 1638 1712 1639 // Multisite installs have their own activation routine 1640 if ( is_multisite() ) { 1713 /** 1714 * If BuddyPress is activated on the main site of the network, use the 1715 * multisite activation routine to create user and eventually a blog 1716 */ 1717 if ( is_multisite() && bp_is_main_site_for_network() ) { 1641 1718 $user = wpmu_activate_signup( $key ); 1642 1719 1643 1720 // If there were errors, add a message and redirect … … function bp_core_activate_signup( $key ) { 1647 1724 1648 1725 $user_id = $user['user_id']; 1649 1726 1727 /** 1728 * Config is not multisite or BuddyPress is activated on a sub site. 1729 * In this case, we need to give capabilities to the user so that he 1730 * appears in the users list once activated. 1731 * 1732 * When BuddyPress is activated on a sub site, only registering an account 1733 * is possible. 1734 */ 1650 1735 } else { 1651 1736 $signups = BP_Signup::get( array( 1652 1737 'activation_key' => $key,