diff --git a/src/bp-groups/admin/css/admin.css b/src/bp-groups/admin/css/admin.css
index c802127..d32bd31 100644
--- a/src/bp-groups/admin/css/admin.css
+++ b/src/bp-groups/admin/css/admin.css
@@ -46,6 +46,9 @@ body.toplevel_page_bp-groups table.groups th#last_active {
line-height: 24px;
color: #666;
}
+#bp-groups-permalink {
+ margin-right: 24px;
+}
.bp-groups-member-type {
position: relative;
}
diff --git a/src/bp-groups/bp-groups-activity.php b/src/bp-groups/bp-groups-activity.php
index c29a03c..cb7c69c 100644
--- a/src/bp-groups/bp-groups-activity.php
+++ b/src/bp-groups/bp-groups-activity.php
@@ -190,6 +190,9 @@ function bp_groups_format_activity_action_group_details_updated( $action, $activ
} elseif ( ! empty( $changed['description']['old'] ) && ! empty( $changed['description']['new'] ) ) {
$action = sprintf( __( '%1$s changed the description of the group %2$s from "%3$s" to "%4$s"', 'buddypress' ), $user_link, $group_link, esc_html( $changed['description']['old'] ), esc_html( $changed['description']['new'] ) );
+ } elseif ( ! empty( $changed['slug']['old'] ) && ! empty( $changed['slug']['new'] ) ) {
+ $action = sprintf( __( '%1$s changed the permalink of the group %2$s.', 'buddypress' ), $user_link, $group_link );
+
}
/**
@@ -461,7 +464,7 @@ function bp_groups_group_details_updated_add_activity( $group_id, $old_group, $n
return false;
}
- if ( ! isset( $old_group->name ) || ! isset( $old_group->description ) ) {
+ if ( ! isset( $old_group->name ) || ! isset( $old_group->slug ) || ! isset( $old_group->description ) ) {
return false;
}
@@ -489,6 +492,13 @@ function bp_groups_group_details_updated_add_activity( $group_id, $old_group, $n
);
}
+ if ( $group->slug !== $old_group->slug ) {
+ $changed['slug'] = array(
+ 'old' => $old_group->slug,
+ 'new' => $group->slug,
+ );
+ }
+
if ( $group->description !== $old_group->description ) {
$changed['description'] = array(
'old' => $old_group->description,
diff --git a/src/bp-groups/bp-groups-admin.php b/src/bp-groups/bp-groups-admin.php
index 77f13e1..c3cdac9 100644
--- a/src/bp-groups/bp-groups-admin.php
+++ b/src/bp-groups/bp-groups-admin.php
@@ -236,19 +236,29 @@ function bp_groups_admin_load() {
$error = 0;
$success_new = $error_new = $success_modified = $error_modified = array();
- // Group name and description are handled with
- // groups_edit_base_group_details().
- if ( !groups_edit_base_group_details( $group_id, $_POST['bp-groups-name'], $_POST['bp-groups-description'], 0 ) ) {
- $error = $group_id;
+ // Name, description and slug must not be empty.
+ if ( empty( $_POST['bp-groups-name'] ) ) {
+ $error = $error - 1;
+ }
+ if ( empty( $_POST['bp-groups-description'] ) ) {
+ $error = $error - 2;
+ }
+ if ( empty( $_POST['bp-groups-slug'] ) ) {
+ $error = $error - 4;
+ }
- // Using negative integers for different error messages... eek!
- if ( empty( $_POST['bp-groups-name'] ) && empty( $_POST['bp-groups-description'] ) ) {
- $error = -3;
- } elseif ( empty( $_POST['bp-groups-name'] ) ) {
- $error = -1;
- } elseif ( empty( $_POST['bp-groups-description'] ) ) {
- $error = -2;
- }
+ /*
+ * Group name, slug, and description are handled with
+ * groups_edit_base_group_details().
+ */
+ if ( ! $error && ! groups_edit_base_group_details( array(
+ 'group_id' => $group_id,
+ 'name' => $_POST['bp-groups-name'],
+ 'slug' => $_POST['bp-groups-slug'],
+ 'description' => $_POST['bp-groups-description'],
+ 'notify_members' => false,
+ ) ) ) {
+ $error = $group_id;
}
// Enable discussion forum.
@@ -518,22 +528,10 @@ function bp_groups_admin_edit() {
}
if ( ! empty( $errors ) ) {
- switch ( $errors ) {
- case -1 :
- $messages[] = __( 'Group name cannot be empty.', 'buddypress' );
- break;
-
- case -2 :
- $messages[] = __( 'Group description cannot be empty.', 'buddypress' );
- break;
-
- case -3 :
- $messages[] = __( 'Group name and description cannot be empty.', 'buddypress' );
- break;
-
- default :
- $messages[] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
- break;
+ if ( $errors < 0 ) {
+ $messages[] = __( 'Group name, slug, and description are all required fields.', 'buddypress' );
+ } else {
+ $messages[] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
}
} elseif ( ! empty( $updated ) ) {
@@ -612,7 +610,11 @@ function bp_groups_admin_edit() {
?>