Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function check_group_name_for_duplicates( $group ) {
- // Check we are at the right step.
- if ( bp_get_groups_current_create_step() !== 'group-details' ) {
- return;
- }
- // Bail if the group name isn't set.
- if ( empty( $group->name ) ) {
- return;
- }
- global $wpdb;
- $table_name = buddypress()->groups->table_name;
- // Check if the group name already exists.
- $retval = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE name = %s", strtolower( $group->name ) ) );
- // If group name exists, display an error message.
- if ( $retval !== NULL ) {
- bp_core_add_message( __( 'Please add your error message here.', 'text-domain' ), 'error' );
- bp_core_redirect( trailingslashit( bp_get_groups_directory_permalink() . 'create/step/group-details' ) );
- }
- }
- add_action( 'groups_group_before_save', 'check_group_name_for_duplicates' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement