Skip to:
Content

BuddyPress.org

Changeset 3347 for trunk/bp-groups.php


Ignore:
Timestamp:
11/03/2010 11:55:29 PM (14 years ago)
Author:
boonebgorges
Message:

Better handling of error messages during the creation of forum topics. Fixes #947

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r3331 r3347  
    477477                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    478478
    479                 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) )
    480                     bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
    481                 else
    482                     bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
    483 
    484                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' );
     479                if ( empty( $_POST['topic_title'] ) )
     480                    $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );
     481                else if ( empty( $_POST['topic_text'] ) )
     482                    $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );
     483               
     484                if ( $error_message ) {
     485                    bp_core_add_message( $error_message, 'error' );
     486                    $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
     487                } else {
     488                    if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) {
     489                        bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
     490                        $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
     491                    } else {
     492                        bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
     493                        $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     494                    }
     495                }
     496               
     497                bp_core_redirect( $redirect );
     498               
    485499            }
    486500
Note: See TracChangeset for help on using the changeset viewer.