Changeset 4180
- Timestamp:
- 08/29/2012 02:52:38 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-core-caps.php
r4179 r4180 726 726 return; 727 727 728 // Bail if not logged in or already a member of this site 729 if ( ! is_user_logged_in() || is_user_member_of_blog() ) 730 return; 731 728 732 // Bail if user is not active 729 733 if ( bbp_is_user_inactive() ) 730 734 return; 731 735 732 // Bail if user is not logged in733 if ( ! is_user_logged_in() )736 // Give the user the default role 737 if ( ! current_user_can( 'bbp_masked' ) ) 734 738 return; 735 739 736 // Give the user the default role 737 if ( current_user_can( 'bbp_masked' ) ) { 738 bbpress()->current_user->set_role( get_option( 'default_role' ) ); 739 } 740 // Make sure the bbp_masked cap doesn't get saved to the DB 741 bbpress()->current_user->remove_cap( 'bbp_masked' ); 742 743 // Set user to default role for blog 744 bbpress()->current_user->set_role( get_option( 'default_role', 'subscriber' ) ); 740 745 } 741 746 … … 745 750 * This function will bail if the forum is not global in a multisite 746 751 * installation of WordPress, or if the user is marked as spam or deleted. 752 * 753 * Note that we do not currently add a capability for the default role of the 754 * site. This is to prevent unauthorized role-based access, since we have no 755 * idea what plugins might be doing to that role. This may change in the future, 756 * so it's best not to rely heavily on this for now. 747 757 * 748 758 * @since bbPress (r3380) … … 771 781 return; 772 782 773 // Assign user the default role to map caps to774 $default_role = get_option( 'default_role', 'subscriber' );775 776 // Get bbPress caps for the default role777 $caps_for_role = bbp_get_caps_for_role( $default_role );778 779 783 // Set all caps to true 780 foreach ( $caps_for_roleas $cap )784 foreach ( bbp_get_caps_for_role() as $cap ) 781 785 $default_caps[$cap] = true; 782 786 783 787 // Add 'read' cap just in case 784 $default_caps['read'] = true;785 788 $default_caps['bbp_masked'] = true; 786 789 … … 790 793 // Assign the role and mapped caps to the current user 791 794 $bbp = bbpress(); 792 $bbp->current_user->roles[0] = $default_role;793 795 $bbp->current_user->caps = $default_caps; 794 796 $bbp->current_user->allcaps = $default_caps;
Note: See TracChangeset
for help on using the changeset viewer.