Skip to:
Content

BuddyPress.org

Changeset 14024


Ignore:
Timestamp:
09/20/2024 06:27:29 PM (10 months ago)
Author:
imath
Message:

Groups Admin: improve feedback messages after group edits

In particular use more meaningful confirmation/error messages when a group member is promoted, demoted, banned, removed or when a user is added to the group.

Props martenw

Fixes #9223
Closes https://github.com/buddypress/buddypress/pull/374

Location:
trunk/src/bp-groups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-admin.php

    r13983 r14024  
    134134
    135135    // Build redirection URL.
    136     $redirect_to = remove_query_arg( array( 'action', 'action2', 'gid', 'deleted', 'error', 'updated', 'success_new', 'error_new', 'success_modified', 'error_modified' ), $_SERVER['REQUEST_URI'] );
     136    $redirect_to = remove_query_arg( array( 'action', 'action2', 'gid', 'deleted', 'error', 'updated' ), $_SERVER['REQUEST_URI'] );
    137137
    138138    $doaction   = bp_admin_list_table_current_bulk_action();
     
    265265    }
    266266
    267 
     267    // Saving group edits.
    268268    if ( $doaction && 'save' == $doaction ) {
    269269        // Get group ID.
    270         $group_id = isset( $_REQUEST['gid'] ) ? (int) $_REQUEST['gid'] : '';
    271 
    272         $redirect_to = add_query_arg( array(
    273             'gid'    => (int) $group_id,
    274             'action' => 'edit'
    275         ), $redirect_to );
     270        $group_id = 0;
     271        if ( isset( $_REQUEST['gid'] ) ) {
     272            $group_id = (int) wp_unslash( $_REQUEST['gid'] );
     273        }
     274
     275        $redirect_to = add_query_arg(
     276            array(
     277                'gid'    => $group_id,
     278                'action' => 'edit'
     279            ),
     280            $redirect_to
     281        );
    276282
    277283        // Check this is a valid form submission.
     
    287293        }
    288294
    289         // Check the form for the updated properties.
    290         // Store errors.
    291         $error = 0;
    292         $success_new = $error_new = $success_modified = $error_modified = array();
    293 
    294         // Name, description and slug must not be empty.
     295        /*
     296         * Check the form for the updated properties.
     297         * Store errors.
     298         */
     299        $error   = array();
     300        $updated = array();
     301
     302        // Name must not be empty.
     303        $group_name = '';
    295304        if ( empty( $_POST['bp-groups-name'] ) ) {
    296             $error = $error - 1;
    297         }
     305            $error['missing'][] = _x( 'name', 'group admin field', 'buddypress' );
     306        } else {
     307            $group_name = sanitize_text_field( wp_unslash( $_POST['bp-groups-name'] ) );
     308        }
     309
     310        // Description must not be empty.
     311        $group_description = '';
    298312        if ( empty( $_POST['bp-groups-description'] ) ) {
    299             $error = $error - 2;
    300         }
     313            $error['missing'][] = _x( 'description', 'group admin field', 'buddypress' );
     314        } else {
     315            $group_description = sanitize_textarea_field( wp_unslash( $_POST['bp-groups-description'] ) );
     316        }
     317
     318        //Slug must not be empty.
     319        $group_slug = '';
    301320        if ( empty( $_POST['bp-groups-slug'] ) ) {
    302             $error = $error - 4;
     321            $error['missing'][] = _x( 'slug', 'group admin field', 'buddypress' );
     322        } else {
     323            $group_slug = sanitize_title( wp_unslash( $_POST['bp-groups-slug'] ) );
    303324        }
    304325
     
    307328         * groups_edit_base_group_details().
    308329         */
    309         if ( ! $error && ! groups_edit_base_group_details( array(
    310                 'group_id'       => $group_id,
    311                 'name'           => $_POST['bp-groups-name'],
    312                 'slug'           => $_POST['bp-groups-slug'],
    313                 'description'    => $_POST['bp-groups-description'],
    314                 'notify_members' => false,
    315             ) ) ) {
    316             $error = $group_id;
     330        if ( ! $error ) {
     331            $updated_group = groups_edit_base_group_details(
     332                array(
     333                    'group_id'       => $group_id,
     334                    'name'           => $group_name,
     335                    'slug'           => $group_slug,
     336                    'description'    => $group_description,
     337                    'notify_members' => false,
     338                )
     339            );
     340
     341            if ( ! $updated_group ) {
     342                $error['group_details'] = _x( 'group details', 'group admin group details error', 'buddypress' );
     343            } else {
     344                if ( $group_name !== $group->name ) {
     345                    $updated['group_details'][] = _x( 'name', 'group admin field', 'buddypress' );
     346                }
     347
     348                if ( $group_description !== $group->description ) {
     349                    $updated['group_details'][] = _x( 'description', 'group admin field', 'buddypress' );
     350                }
     351
     352                if ( $group_slug !== $group->slug ) {
     353                    $updated['group_details'][] = _x( 'slug', 'group admin field', 'buddypress' );
     354                }
     355            }
    317356        }
    318357
    319358        // Enable discussion forum.
    320         $enable_forum   = ( isset( $_POST['group-show-forum'] ) ) ? 1 : 0;
     359        $enable_forum = 0;
     360        if ( isset( $_POST['group-show-forum'] ) ) {
     361            $enable_forum = 1;
     362        };
    321363
    322364        /**
     
    328370         */
    329371        $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
    330         $status         = ( in_array( $_POST['group-status'], (array) $allowed_status ) ) ? $_POST['group-status'] : 'public';
     372        $status         = 'public';
     373        if ( isset( $_POST['group-status'] ) ) {
     374            $sent_status = sanitize_text_field( wp_unslash( $_POST['group-status'] ) );
     375
     376            if ( in_array( $sent_status, (array) $allowed_status, true ) ) {
     377                $status = $sent_status;
     378            }
     379        }
    331380
    332381        /**
     
    337386         * @param array $value Array of allowed invite statuses.
    338387         */
    339         $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) );
    340         $invite_status         = in_array( $_POST['group-invite-status'], (array) $allowed_invite_status ) ? $_POST['group-invite-status'] : 'members';
    341 
    342         if ( !groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status ) ) {
    343             $error = $group_id;
     388        $allowed_invite_status     = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) );
     389        $invite_status             = 'members';
     390        $is_updating_invite_status = false;
     391        if ( isset( $_POST['group-invite-status'] ) ) {
     392            $sent_invite_status = sanitize_text_field( wp_unslash( $_POST['group-invite-status'] ) );
     393
     394            if ( in_array( $sent_invite_status, (array) $allowed_invite_status, true ) ) {
     395                $invite_status             = $sent_invite_status;
     396                $is_updating_invite_status = $invite_status !== groups_get_groupmeta( $group->id, 'invite_status' );
     397            }
     398        }
     399
     400        if ( ! groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status ) ) {
     401            $error['group_settings'] = _x( 'group settings', 'group admin group details error', 'buddypress' );
     402        } else {
     403            if ( $is_updating_invite_status ) {
     404                $updated['group_settings'][] = _x( 'group invite status', 'group admin group details updated', 'buddypress' );
     405            }
     406
     407            if ( $status !== $group->status ) {
     408                $updated['group_settings'][] = _x( 'group status', 'group admin group details updated', 'buddypress' );
     409            }
    344410        }
    345411
    346412        // Process new members.
    347413        $user_names = array();
    348 
    349414        if ( ! empty( $_POST['bp-groups-new-members'] ) ) {
    350             $user_names = array_merge( $user_names, explode( ',', $_POST['bp-groups-new-members'] ) );
     415            $sent_usernames = array_map( 'sanitize_user', explode( ',', wp_unslash( $_POST['bp-groups-new-members'] ) ) );
     416            $user_names     = array_merge( $user_names, $sent_usernames );
    351417        }
    352418
     
    366432
    367433                if ( empty( $user ) ) {
    368                     $error_new[] = $un;
     434                    $error['new_user'][] = $un;
    369435                } else {
    370436                    if ( ! groups_join_group( $group_id, $user->ID ) ) {
    371                         $error_new[]  = $un;
     437                        $error['new_user'][] = $un;
    372438                    } else {
    373                         $success_new[] = $un;
     439                        $updated['new_user'][] = $un;
    374440                    }
    375441                }
     
    383449        // Process member role changes.
    384450        if ( ! empty( $_POST['bp-groups-role'] ) && ! empty( $_POST['bp-groups-existing-role'] ) ) {
     451            $new_group_role     = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['bp-groups-role'] ) );
     452            $current_group_role = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['bp-groups-existing-role'] ) );
    385453
    386454            // Before processing anything, make sure you're not
    387455            // attempting to remove the all user admins.
    388456            $admin_count = 0;
    389             foreach ( (array) $_POST['bp-groups-role'] as $new_role ) {
     457            foreach ( $new_group_role as $new_role ) {
    390458                if ( 'admin' == $new_role ) {
    391459                    $admin_count++;
     
    395463
    396464            if ( ! $admin_count ) {
    397 
    398                 $redirect_to = add_query_arg( 'no_admins', 1, $redirect_to );
    399                 $error = $group_id;
     465                $error['no_admins'] = 1;
    400466
    401467            } else {
    402468
    403469                // Process only those users who have had their roles changed.
    404                 foreach ( (array) $_POST['bp-groups-role'] as $user_id => $new_role ) {
     470                foreach ( $new_group_role as $user_id => $new_role ) {
    405471                    $user_id = (int) $user_id;
    406472
    407                     $existing_role = isset( $_POST['bp-groups-existing-role'][$user_id] ) ? $_POST['bp-groups-existing-role'][$user_id] : '';
    408 
    409                     if ( $existing_role != $new_role ) {
     473                    $existing_role = isset( $current_group_role[ $user_id ] ) ? $current_group_role[ $user_id ] : '';
     474
     475                    if ( $existing_role !== $new_role ) {
    410476                        $result = false;
    411477
     
    414480                                // Admin to mod is a demotion. Demote to
    415481                                // member, then fall through.
    416                                 if ( 'admin' == $existing_role ) {
    417                                     groups_demote_member( $user_id, $group_id );
     482                                if ( 'admin' === $existing_role ) {
     483                                    $result = groups_demote_member( $user_id, $group_id );
    418484                                }
    419485
     
    421487                                // If the user was banned, we must
    422488                                // unban first.
    423                                 if ( 'banned' == $existing_role ) {
     489                                if ( 'banned' === $existing_role ) {
    424490                                    groups_unban_member( $user_id, $group_id );
    425491                                }
     
    433499                            case 'member' :
    434500
    435                                 if ( 'admin' == $existing_role || 'mod' == $existing_role ) {
     501                                if ( 'admin' === $existing_role || 'mod' === $existing_role ) {
    436502                                    $result = groups_demote_member( $user_id, $group_id );
    437                                 } elseif ( 'banned' == $existing_role ) {
     503                                } elseif ( 'banned' === $existing_role ) {
    438504                                    $result = groups_unban_member( $user_id, $group_id );
    439505                                }
     
    456522                        // Store the success or failure.
    457523                        if ( $result ) {
    458                             $success_modified[] = $user_id;
     524                            $updated['roles'][ $new_role ][] = $user_id;
    459525                        } else {
    460                             $error_modified[]  = $user_id;
     526                            $error['roles'][ $new_role ][] = $user_id;
    461527                        }
    462528                    }
     
    474540        do_action( 'bp_group_admin_edit_after', $group_id );
    475541
     542        $redirect_args = array();
     543
    476544        // Create the redirect URL.
    477545        if ( $error ) {
    478546            // This means there was an error updating group details.
    479             $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
    480         } else {
     547            $redirect_args['error'] = $error;
     548        }
     549
     550        if ( $updated ) {
    481551            // Group details were update successfully.
    482             $redirect_to = add_query_arg( 'updated', 1, $redirect_to );
    483         }
    484 
    485         if ( !empty( $success_new ) ) {
    486             $success_new = implode( ',', array_filter( $success_new, 'urlencode' ) );
    487             $redirect_to = add_query_arg( 'success_new', $success_new, $redirect_to );
    488         }
    489 
    490         if ( !empty( $error_new ) ) {
    491             $error_new = implode( ',', array_filter( $error_new, 'urlencode' ) );
    492             $redirect_to = add_query_arg( 'error_new', $error_new, $redirect_to );
    493         }
    494 
    495         if ( !empty( $success_modified ) ) {
    496             $success_modified = implode( ',', array_filter( $success_modified, 'urlencode' ) );
    497             $redirect_to = add_query_arg( 'success_modified', $success_modified, $redirect_to );
    498         }
    499 
    500         if ( !empty( $error_modified ) ) {
    501             $error_modified = implode( ',', array_filter( $error_modified, 'urlencode' ) );
    502             $redirect_to = add_query_arg( 'error_modified', $error_modified, $redirect_to );
    503         }
     552            $redirect_args['updated'] = $updated;
     553        }
     554
     555        $redirect_to = add_query_arg( $redirect_args, $redirect_to );
    504556
    505557        /**
     
    558610
    559611    // If the user has just made a change to a group, build status messages.
    560     if ( ! empty( $_REQUEST['no_admins'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) || ! empty( $_REQUEST['error_new'] ) || ! empty( $_REQUEST['success_new'] ) || ! empty( $_REQUEST['error_modified'] ) || ! empty( $_REQUEST['success_modified'] ) ) {
    561         $no_admins        = ! empty( $_REQUEST['no_admins']        ) ? 1                                             : 0;
    562         $errors           = ! empty( $_REQUEST['error']            ) ? $_REQUEST['error']                            : '';
    563         $updated          = ! empty( $_REQUEST['updated']          ) ? $_REQUEST['updated']                          : '';
    564         $error_new        = ! empty( $_REQUEST['error_new']        ) ? explode( ',', $_REQUEST['error_new'] )        : array();
    565         $success_new      = ! empty( $_REQUEST['success_new']      ) ? explode( ',', $_REQUEST['success_new'] )      : array();
    566         $error_modified   = ! empty( $_REQUEST['error_modified']   ) ? explode( ',', $_REQUEST['error_modified'] )   : array();
    567         $success_modified = ! empty( $_REQUEST['success_modified'] ) ? explode( ',', $_REQUEST['success_modified'] ) : array();
    568 
    569         if ( ! empty( $no_admins ) ) {
    570             $messages[] = __( 'You cannot remove all administrators from a group.', 'buddypress' );
    571         }
    572 
    573         if ( ! empty( $errors ) ) {
    574             if ( $errors < 0 ) {
    575                 $messages[] = __( 'Group name, slug, and description are all required fields.', 'buddypress' );
    576             } else {
    577                 $messages[] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
     612    if ( ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) {
     613        $group_roles = bp_groups_get_group_roles();
     614
     615        // Fake a group role for removed members.
     616        $group_roles[] = (object) array(
     617            'id' => 'remove',
     618        );
     619
     620        $error = array();
     621        if ( ! empty( $_REQUEST['error'] ) ) {
     622            $error = (array) wp_unslash( $_REQUEST['error'] );
     623
     624            foreach ( $error as $error_key => $error_data ) {
     625                if ( 'missing' === $error_key ) {
     626                    $error_data = implode( ', ', $error_data );
     627
     628                    /* translators: %s is a comma separated list of required fields. */
     629                    $messages['error'][] = sprintf( __( '%s are required fields, please make sure to define their values.', 'buddypress' ), esc_html( $error_data ) );
     630
     631                } elseif ( 'group_details' === $error_key ) {
     632                    $messages['error'][] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
     633
     634                } elseif ( 'group_settings' === $error_key ) {
     635                    $messages['error'][] = __( 'An error occurred when trying to update your group settings.', 'buddypress' );
     636
     637                } elseif ( 'new_user' === $error_key ) {
     638                    $error_data = implode( ', ', $error_data );
     639
     640                    /* translators: %s: comma separated list of usernames */
     641                    $messages['error'][] = sprintf( __( 'The following users could not be added to the group: %s.', 'buddypress' ), esc_html( $error_data ) );
     642
     643                } elseif ( 'no_admins' === $error_key ) {
     644                    $messages['error'][] = __( 'You cannot remove all administrators from a group.', 'buddypress' );
     645
     646                    // Deal with promoted/demoted members.
     647                } elseif ( 'roles' === $error_key ) {
     648                    foreach ( $group_roles as $group_role ) {
     649                        if ( isset( $error_data[ $group_role->id ] ) ) {
     650                            $group_members_un = bp_groups_admin_get_usernames_from_ids( $error_data[ $group_role->id ] );
     651
     652                            if ( isset( $group_role->plural_name ) ) {
     653                                $messages['error'][] = sprintf(
     654                                    /* translators: 1: comma separated list of usernames. 2: group role plural name. */
     655                                    __( 'An error occured when trying to update the following members: %1$s as %2$s.', 'buddypress' ),
     656                                    '<em>' . esc_html( implode( ', ', $group_members_un ) ) . '</em>',
     657                                    esc_html( $group_role->plural_name )
     658                                );
     659
     660                                // Deal with "banned" role.
     661                            } elseif ( 'banned' === $group_role->id ) {
     662                                /* translators: %s: comma separated list of usernames. */
     663                                $messages['error'][] = sprintf( __( 'An error occured when trying to ban the following members: %s.', 'buddypress' ), '<em>' . esc_html( implode( ', ', $group_members_un ) ) . '</em>' );
     664
     665                                // Deal with fake "remove" role.
     666                            } elseif ( 'remove' === $group_role->id ) {
     667                                /* translators: %s: comma separated list of usernames. */
     668                                $messages['error'][] = sprintf( __( 'An error occured when trying to remove the following members: %s.', 'buddypress' ), '<em>' . esc_html( implode( ', ', $group_members_un ) ) . '</em>' );
     669                            }
     670                        }
     671                    }
     672                }
    578673            }
    579 
    580         } elseif ( ! empty( $updated ) ) {
    581             $messages[] = __( 'The group has been updated successfully.', 'buddypress' );
    582         }
    583 
    584         if ( ! empty( $error_new ) ) {
    585             /* translators: %s: comma separated list of usernames */
    586             $messages[] = sprintf( __( 'The following users could not be added to the group: %s', 'buddypress' ), '<em>' . esc_html( implode( ', ', $error_new ) ) . '</em>' );
    587         }
    588 
    589         if ( ! empty( $success_new ) ) {
    590             /* translators: %s: comma separated list of usernames */
    591             $messages[] = sprintf( __( 'The following users were successfully added to the group: %s', 'buddypress' ), '<em>' . esc_html( implode( ', ', $success_new ) ) . '</em>' );
    592         }
    593 
    594         if ( ! empty( $error_modified ) ) {
    595             $error_modified = bp_groups_admin_get_usernames_from_ids( $error_modified );
    596             /* translators: %s: comma separated list of usernames */
    597             $messages[] = sprintf( __( 'An error occurred when trying to modify the following members: %s', 'buddypress' ), '<em>' . esc_html( implode( ', ', $error_modified ) ) . '</em>' );
    598         }
    599 
    600         if ( ! empty( $success_modified ) ) {
    601             $success_modified = bp_groups_admin_get_usernames_from_ids( $success_modified );
    602             /* translators: %s: comma separated list of usernames */
    603             $messages[] = sprintf( __( 'The following members were successfully modified: %s', 'buddypress' ), '<em>' . esc_html( implode( ', ', $success_modified ) ) . '</em>' );
    604         }
    605     }
    606 
    607     $is_error = ! empty( $no_admins ) || ! empty( $errors ) || ! empty( $error_new ) || ! empty( $error_modified );
     674        }
     675
     676        $updated = array();
     677        if ( ! empty( $_REQUEST['updated'] ) ) {
     678            $updated = (array) wp_unslash( $_REQUEST['updated'] );
     679
     680            foreach ( $updated as $updated_key => $updated_data ) {
     681                if ( 'roles' === $updated_key ) {
     682                    foreach ( $group_roles as $group_role ) {
     683                        if ( isset( $updated_data[ $group_role->id ] ) ) {
     684                            $group_members_un = bp_groups_admin_get_usernames_from_ids( $updated_data[ $group_role->id ] );
     685
     686                            if ( isset( $group_role->plural_name ) ) {
     687                                $messages['updated'][] = sprintf(
     688                                    /* translators: 1: comma separated list of usernames. 2: group role plural name. */
     689                                    __( 'The following members: %1$s are now %2$s.', 'buddypress' ),
     690                                    '<em>' . esc_html( implode( ', ', $group_members_un ) ) . '</em>',
     691                                    esc_html( $group_role->plural_name )
     692                                );
     693
     694                                // Deal with "banned" role.
     695                            } elseif ( 'banned' === $group_role->id ) {
     696                                /* translators: %s: comma separated list of usernames */
     697                                $messages['updated'][] = sprintf( __( 'The following members were banned: %s.', 'buddypress' ), '<em>' . esc_html( implode( ', ', $group_members_un ) ) . '</em>' );
     698
     699                                // Deal with fake "remove" role.
     700                            } elseif ( 'remove' === $group_role->id ) {
     701                                /* translators: %s: comma separated list of usernames */
     702                                $messages['updated'][] = sprintf( __( 'The following members were removed: %s.', 'buddypress' ), '<em>' . esc_html( implode( ', ', $group_members_un ) ) . '</em>' );
     703                            }
     704                        }
     705                    }
     706                } else {
     707                    $edited_data = implode( ', ', $updated_data );
     708
     709                    if ( 'group_details' === $updated_key ) {
     710                        /* translators: %s: comma separated list of group details */
     711                        $messages['updated'][] = sprintf( __( 'These details about the group were successfully updated: %s.', 'buddypress' ), esc_html( $edited_data ) );
     712
     713                    } elseif ( 'group_settings' === $updated_key ) {
     714                        /* translators: %s: comma separated list of group settings */
     715                        $messages['updated'][] = sprintf( __( 'These settings about the group were successfully updated: %s.', 'buddypress' ), esc_html( $edited_data ) );
     716
     717                    } elseif ( 'new_user' === $updated_key ) {
     718                        /* translators: %s: comma separated list of usernames */
     719                        $messages['updated'][] = sprintf( __( 'The following users were successfully added to the group: %s.', 'buddypress' ), esc_html( $edited_data ) );
     720                    }
     721                }
     722            }
     723        }
     724    }
    608725
    609726    // Get the group from the database.
     
    613730
    614731    // Construct URL for form.
    615     $form_url   = remove_query_arg( array( 'action', 'deleted', 'no_admins', 'error', 'error_new', 'success_new', 'error_modified', 'success_modified' ), $_SERVER['REQUEST_URI'] );
     732    $form_url   = remove_query_arg( array( 'action', 'deleted', 'error', 'updated' ), $_SERVER['REQUEST_URI'] );
    616733    $form_url   = add_query_arg( 'action', 'save', $form_url );
    617734    $create_url = bp_groups_get_create_url();
     
    637754        <hr class="wp-header-end">
    638755
    639         <?php // If the user has just made a change to an group, display the status messages. ?>
    640756        <?php if ( ! empty( $messages ) ) : ?>
    641             <div id="moderated" class="<?php echo esc_attr( ( $is_error ) ? 'error' : 'updated' ); ?> notice is-dismissible"><p><?php echo implode( "</p><p>", array_map( 'wp_kses_post', $messages ) ); ?></p></div>
     757            <?php foreach ( $messages as $type => $messages_list ) : ?>
     758                <div id="moderated" class="<?php echo esc_attr( $type ); ?> notice is-dismissible"><p><?php echo implode( "</p><p>", array_map( 'wp_kses_post', $messages_list ) ); ?></p></div>
     759            <?php endforeach; ?>
    642760        <?php endif; ?>
    643761
  • trunk/src/bp-groups/bp-groups-functions.php

    r13996 r14024  
    424424function groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status = false, $parent_id = false ) {
    425425
    426     $group = groups_get_group( $group_id );
     426    $group               = groups_get_group( $group_id );
    427427    $group->enable_forum = $enable_forum;
    428428
     
    431431     * from private and there are outstanding membership requests, auto-accept those requests.
    432432     */
    433     if ( 'private' == $group->status && 'public' == $status )
     433    if ( 'private' === $group->status && 'public' === $status ) {
    434434        groups_accept_all_pending_membership_requests( $group->id );
     435    }
    435436
    436437    // Now update the status.
     
    442443    }
    443444
    444     if ( !$group->save() )
     445    if ( ! $group->save() ) {
    445446        return false;
     447    }
    446448
    447449    // Set the invite status.
    448     if ( $invite_status )
     450    if ( $invite_status ) {
    449451        groups_update_groupmeta( $group->id, 'invite_status', $invite_status );
     452    }
    450453
    451454    groups_update_groupmeta( $group->id, 'last_activity', bp_core_current_time() );
     
    13591362            'id'           => 'admin',
    13601363            'name'         => __( 'Administrator', 'buddypress' ),
     1364            'plural_name'  => _x( 'administrators', 'group role plural name', 'buddypress' ),
    13611365            'is_admin'     => true,
    13621366            'is_banned'    => false,
     
    13671371            'id'           => 'mod',
    13681372            'name'         => __( 'Moderator', 'buddypress' ),
     1373            'plural_name'  => _x( 'moderators', 'group role plural name', 'buddypress' ),
    13691374            'is_admin'     => false,
    13701375            'is_banned'    => false,
     
    13751380            'id'           => 'member',
    13761381            'name'         => __( 'Member', 'buddypress' ),
     1382            'plural_name'  => _x( 'members', 'group role plural name', 'buddypress' ),
    13771383            'is_admin'     => false,
    13781384            'is_banned'    => false,
Note: See TracChangeset for help on using the changeset viewer.