Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ideadude committed Oct 14, 2020
2 parents 80146c5 + d50894e commit b5b9ee3
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 25 deletions.
Binary file modified assets/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions includes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,19 @@ function pmpro_bp_user_can_join_group( $group_id, $user_id = null ) {
if ( pmpro_bp_user_can( 'groups_join', $user_id ) ) {
// they can join any group
$can_join = true;
} else {
// check if they can joint his specific group
} elseif ( ! empty( $group_id ) ) {
// check if they can join this specific group
$can_join = false;
$pmpro_bp_options = pmpro_bp_get_user_options( $user_id );

if ( is_array( $pmpro_bp_options['pmpro_bp_group_automatic_add'] ) && in_array( $group_id, $pmpro_bp_options['pmpro_bp_group_automatic_add'] ) ) {
$can_join = true;
}
if ( is_array( $pmpro_bp_options['pmpro_bp_group_can_request_invite'] ) && in_array( $group_id, $pmpro_bp_options['pmpro_bp_group_can_request_invite'] ) ) {
$can_join = true;
}
} else {
$can_join = false;
}

return $can_join;
Expand Down
10 changes: 8 additions & 2 deletions includes/pmpro-buddypress-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ function pmpro_bp_add_admin_menu_page() {
add_action( 'admin_menu', 'pmpro_bp_add_admin_menu_page' );

function pmpro_bp_buddpress_admin_page() {

global $pmpro_pages, $msg, $msgt;

//get/set settings
if(!empty($_REQUEST['savesettings'])) {
// Non-member user Restrictions
Expand Down Expand Up @@ -54,6 +57,10 @@ function pmpro_bp_buddpress_admin_page() {
// General Settings
update_option( 'pmpro_bp_registration_page', $_POST['pmpro_bp_register'] );
update_option( 'pmpro_bp_show_level_on_bp_profile', $_POST['pmpro_bp_level_profile'], 'no' ) ;

// Assume Success
$msg = 1;
$msgt = __( 'Your settings have been updated.', 'pmpro-buddypress' );
}

$pmpro_bp_register = get_option( 'pmpro_bp_registration_page' );
Expand All @@ -76,9 +83,8 @@ function pmpro_bp_buddpress_admin_page() {
<p><?php printf( __( 'Integrate and manage your BuddyPress Community using Paid Memberships Pro. <a href="%s" target="_blank">Read the documentation</a> for more information about this Add On.', 'pmpro-buddypress' ), 'https://www.paidmembershipspro.com/add-ons/buddypress-integration/' ); ?></p>

<h3 class="topborder"><?php esc_attr_e( 'Page Settings', 'pmpro-buddypress' ); ?></h3>
<p><?php esc_attr_e( 'This plugin redirects users to a specific page if they try to access restricted BuddyPress features. The user is redirected to the page assigned as the "Access Restricted" page under Memberships > Page Settings.', 'pmpro-buddypress' ); ?></p>
<p><?php esc_attr_e( 'This plugin redirects users to a specific page if they try to access restricted BuddyPress features. The user is redirected to the page assigned as the "Access Restricted" page under Memberships > Settings > Page Settings.', 'pmpro-buddypress' ); ?></p>
<?php
global $pmpro_pages;
$pmprobp_restricted_page = $pmpro_pages['pmprobp_restricted'];
if ( ! empty( $pmprobp_restricted_page ) ) {
$msgt = '<span class="dashicons dashicons-yes"></span>' . esc_attr( '"Access Restricted" page is configured.', 'pmpro-buddypress' );
Expand Down
35 changes: 32 additions & 3 deletions includes/restrictions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,53 @@ function pmpro_bp_bp_get_group_create_button( $button_args ) {

if(!pmpro_bp_user_can( 'pmpro_bp_group_creation' ) ) {
$button_args['link_href'] = get_permalink($pmpro_pages['pmprobp_restricted']);
$button_args['button_element'] = 'a';
}

return $button_args;
}
add_filter( 'bp_get_group_create_button', 'pmpro_bp_bp_get_group_create_button', 10, 1 );

/**
* Prevent users from creating groups
* if their level doesn't allow it.
*/
function pmpro_bp_bp_user_can_create_groups( $can_create, $restricted ) {
if ( $can_create && ! pmpro_bp_user_can( 'pmpro_bp_group_creation' ) && ! current_user_can( 'manage_options' ) ) {
$can_create = false;
}

return $can_create;
}
add_filter( 'bp_user_can_create_groups', 'pmpro_bp_bp_user_can_create_groups', 10, 2);

/**
* Hide the Join Group button if joining groups is restricted
*/
function pmpro_bp_bp_get_groups_join_button( $button_args, $group ) {
if( ( $button_args['id'] === 'join_group' || $button_args['id'] === 'request_membership' ) && !pmpro_bp_user_can_join_group( $group->id ) ) {
function pmpro_bp_disable_group_buttons( $button_args, $group ) {
if( ( $button_args['id'] === 'join_group' || $button_args['id'] === 'request_membership' || $button_args['id'] === 'group_membership' ) && !pmpro_bp_user_can_join_group( $group->id ) ) {
global $pmpro_pages;
$button_args['link_href'] = get_permalink($pmpro_pages['pmprobp_restricted']);
$button_args['link_class'] = str_replace( 'join-group', '', $button_args['link_class'] );
$button_args['button_element'] = 'a';
}

return $button_args;
}
add_filter( 'bp_get_group_join_button', 'pmpro_bp_bp_get_groups_join_button', 10, 2);
add_filter( 'bp_get_group_join_button', 'pmpro_bp_disable_group_buttons', 10, 2);

/**
* With the Nouveau theme, some attributes get overwritten,
* so we need to filter them again later.
*/
function pmpro_bp_disable_nouveau_group_buttons( $buttons, $group ) {
foreach( $buttons as &$button ) {
$button = pmpro_bp_disable_group_buttons( $button, $group );
}

return $buttons;
}
add_filter( 'bp_nouveau_get_groups_buttons', 'pmpro_bp_disable_nouveau_group_buttons', 10, 2 );

/**
* Remove Nav Link to request an invite
Expand Down
2 changes: 1 addition & 1 deletion pmpro-buddypress.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Paid Memberships Pro - BuddyPress Add On
Plugin URI: https://www.paidmembershipspro.com/add-ons/buddypress-integration
Description: Manage access to your BuddyPress Community using Paid Memberships Pro.
Version: 1.2.5
Version: 1.2.6
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
Text Domain: pmpro-buddypress
Expand Down
41 changes: 24 additions & 17 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@
Contributors: strangerstudios, great-h-master
Tags: paid memberships pro, pmpro, buddypress
Requires at least: 4
Tested up to: 5.4
Stable tag: 1.2.5
Tested up to: 5.5
Stable tag: 1.2.6

Manage access to your BuddyPress Community using Paid Memberships Pro

== Description ==

= Manage access to your BuddyPress Community using Paid Memberships Pro. =

This BuddyPress Integration for Paid Memberships Pro allows you to restrict access to specific features of your BuddyPress community by membership level, allowing you to build a custom, private, and flexible members-only community.
Restrict access to specific features of your BuddyPress community by membership level, allowing you to build a custom, private, and flexible members-only community.

The plugin requires BuddyPress and Paid Memberships Pro to be installed and activated.

= Official Paid Memberships Pro Add On =

This is an official Add On for [Paid Memberships Pro](https://www.paidmembershipspro.com), the most complete member management and membership subscriptions plugin for WordPress.

= General features of this Integration include: =
1. Restrict BuddyPress Features by Membership Level
1. Assign or Invite Members to BuddyPress Groups by Membership Level
1. Assign BuddyPress Member Types by Membership Level
1. Show the Member's Level Name on BuddyPress Profile
1. Use the BuddyPress Registration Process in place of Paid Memberships Pro
1. [Restrict BuddyPress Features by Membership Level](https://www.paidmembershipspro.com/add-ons/buddypress-integration/#level_settings)
1. [Assign or Invite Members to BuddyPress Groups by Membership Level](https://www.paidmembershipspro.com/add-ons/buddypress-integration/#members)
1. [Assign BuddyPress Member Types by Membership Level](https://www.paidmembershipspro.com/add-ons/buddypress-integration/#member_types)
1. [Show the Member's Level Name on BuddyPress Profile](https://www.paidmembershipspro.com/add-ons/buddypress-integration/#level_name)
1. [Use the BuddyPress Registration Process in place of Paid Memberships Pro](https://www.paidmembershipspro.com/add-ons/buddypress-integration/#registration)

= Specific areas of BuddyPress that can be restricted by Membership Level include: =
1. Group Creation: Can members of this level create BuddyPress Groups?
Expand All @@ -40,32 +44,32 @@ The plugin requires BuddyPress and Paid Memberships Pro to be installed and acti
= Download, Install and Activate! =
1. Download the latest version of the plugin.
1. Unzip the downloaded file to your computer.
1. Upload the /pmpro-buddypress/ directory to the /wp-content/plugins/ directory of your site.
1. Upload the `/pmpro-buddypress/` directory to the `/wp-content/plugins/` directory of your site.
1. Activate the plugin through the 'Plugins' menu in WordPress.

= Page Settings =
This plugin redirects users to a specific page if they try to access restricted BuddyPress features. The user is redirected to the page assigned as the "Access Restricted" page under Memberships > Page Settings.
This plugin redirects users to a specific page if they try to access restricted BuddyPress features. The user is redirected to the page assigned as the ["Access Restricted" page under Memberships > Settings > Page Settings](https://www.paidmembershipspro.com/add-ons/buddypress-integration/#page_settings).

1. Navigate to Memberships -> Page Settings and choose (or generate) a page for the "Access Restricted" page.
1. Navigate to Memberships > Settings > Page Settings and choose (or generate) a page for the "Access Restricted" page.
1. Be sure to include the [pmpro_buddypress_restricted] shortcode in the page content.
1. Save Settings

= Membership Level Settings =
1. Navigate to Memberships -> Membership Levels and choose a level to edit.
1. Navigate to Memberships > Settings > Membership Levels and choose a level to edit.
1. Under the "BuddyPress Restrictions" section, change "Unlock BuddyPress?" to your desired option.
1. You can choose to give members of that level access to all of BuddyPress (and thus lock all users without that level from accessing BuddyPress features) or choose specific features that require that membership level.
1. If you are planning to restrict BuddyPress for more than one level, the plugin will check if the user has ANY level giving them access to those features.

= Managing Members and Groups in BuddyPress =
1. Navigate to Memberships -> Membership Levels.
1. Navigate to Memberships > Settings > Membership Levels.
1. Select a level to edit or create a new level.
1. Under "BuddyPress Group Membership", select the groups you would like to add or invite members to.
1. Users will be automatically added to any group checked in the "Add to these Groups" option.
1. Users will be invited (can manually choose to join) any group checked in the "Invite to these Groups" option.
1. Save Settings.

= Creating and Assigning Member Types by Membership Level =
1. Navigate to Memberships > Membership Levels.
1. Navigate to Memberships > Settings > Membership Levels.
1. Select a level to edit or create a new level.
1. Under "BuddyPress Member Types", select the member types you would like to assign for members of this level.
1. Save Settings.
Expand All @@ -75,7 +79,7 @@ Note that BuddyPress Member Types must be created through custom code. [This pos
= Non-member User Settings =
Some of your WordPress users may not have a membership level in Paid Memberships Pro. This plugin allows you to set how BuddyPress should be locked down for these users without a membership level.

1. Navigate to Memberships -> PMPro BuddyPress in the WP Dashboard.
1. Navigate to Memberships > Settings > PMPro BuddyPress in the WP Dashboard.
1. Under the "Non-member User Settings" section, change "Unlock BuddyPress?" to your desired option.
1. You can choose to lock access to all of BuddyPress, give non-member users access to all of BuddyPress or choose specific features that they can access.

Expand All @@ -94,11 +98,14 @@ This plugin also allows you to use the BuddyPress user registration process (in
== Screenshots ==

1. **PMPro BuddyPress Settings** - Explore and manage the features of the integration plugin, including Page Settings, Membership Level Settings, and General Settings.
2. **Membership Level Settings** - Define how you want to restrict BuddyPress for each Membership Level under Memberships > Edit Level.
3. **Group and Member Type Settings** - Add or Invite Members to Groups and Assign Member Types by Membership Level under Memberships > Edit Level.
2. **Membership Level Settings** - Define how you want to restrict BuddyPress for each Membership Level under Memberships > Settings > Memberships Levels > Edit.
3. **Group and Member Type Settings** - Add or Invite Members to Groups and Assign Member Types by Membership Level under Memberships > Settings > Memberships Levels > Edit.

== Changelog ==

= 1.2.6 - 2020-10-14 =
* BUG FIX: Fixed issue where the create group and join group buttons were not being disabled for users who shouldn't have had permission to create or join groups.

= 1.2.5 - 2020-04-06 =
* BUG FIX: Fixed issue where users were redirected away from the profile page if all of BuddyPress was locked down.
* BUG FIX: Fixed issues with adding users to groups.
Expand Down

0 comments on commit b5b9ee3

Please sign in to comment.