Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/09/2015 12:24:15 AM (7 years ago)
Author:
r-a-y
Message:

Groups Admin: Add better contextual errors when editing a group.

Previously, when attempting to save an empty group title or description,
the error message was ambiguous, which could lead to confusing situations.

This commit addresses this (albeit in a workaround way - feel free to yell
at r-a-y for this one).

Fixes #5854.

File:
1 edited

Legend:

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

    r9315 r9321  
    212212        if ( !groups_edit_base_group_details( $group_id, $_POST['bp-groups-name'], $_POST['bp-groups-description'], 0 ) ) {
    213213            $error = $group_id;
     214
     215            // using negative integers for different error messages... eek!
     216            if ( empty( $_POST['bp-groups-name'] ) && empty( $_POST['bp-groups-description'] ) ) {
     217                $error = -3;
     218            } elseif ( empty( $_POST['bp-groups-name'] ) ) {
     219                $error = -1;
     220            } elseif ( empty( $_POST['bp-groups-description'] ) ) {
     221                $error = -2;
     222            }
    214223        }
    215224
     
    456465
    457466        if ( ! empty( $errors ) ) {
    458             $messages[] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
     467            switch ( $errors ) {
     468                case -1 :
     469                    $messages[] = __( 'Group name cannot be empty.', 'buddypress' );
     470                    break;
     471
     472                case -2 :
     473                    $messages[] = __( 'Group description cannot be empty.', 'buddypress' );
     474                    break;
     475
     476                case -3 :
     477                    $messages[] = __( 'Group name and description cannot be empty.', 'buddypress' );
     478                    break;
     479
     480                default :
     481                    $messages[] = __( 'An error occurred when trying to update your group details.', 'buddypress' );
     482                    break;
     483            }
     484
    459485        } elseif ( ! empty( $updated ) ) {
    460486            $messages[] = __( 'The group has been updated successfully.', 'buddypress' );
Note: See TracChangeset for help on using the changeset viewer.