Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to filter the names of new groups during group creation?


  • Mike Stumpf
    Participant

    @mstumpf

    WP-3.5.2 BP-1.8 Site-http://mikestumpf.com/mu-cbox/

    Hello,

    I am trying to make a simple function to filter out “bad” group names and names that are already taken, similar to the filtering done when creating a group blog, but I cannot make sense of the BuddyPress-specific pieces of the code.

    I have the files I probably need narrowed down to:

    …/wp-content/plugins/buddypress/bp-themes/bp-default/groups/create.php (for inserting the function call)
    &
    …/wp-content/plugins/buddypress/bp-themes/bp-default/groups/groups-loop.php (for using the methods for retrieving groups, like on the Group Directory page)

    I am stuck on finding where exactly in the code the group is being created and making sense of calls like: ” do_action( ‘bp_after_group_details_creation_step’ );” in create.php.

    Currently, when groups are created with the same name, the second group has a “-” and a string of number appended to it. I cannot find where this is happening in the code either.

    Can anybody help me with this?

    Here is what I have of the function so far:

    
    // Validate new group name
    function group_name_check($groupNameToCheck)
    {
    while (bp_groups() ) : bp_the_group();
    if(bp_get_group_name() = $groupNameToCheck)
    {
    $error = "something here"
    }
    endif;
    return $error;
    endwhile;
    }
Viewing 1 replies (of 1 total)

  • meg@info
    Participant

    @megainfo

    Hi,

    Try this filter

    
    add_filter('groups_group_name_before_save','mygroups_group_name_before_save',10,2);
    function mygroups_group_name_before_save($group_name, $group_id){
      // your code to check the $group_name value 
      return $group_name;
    }
    

    you can check the code in bp-groups-classes.php for more informations

Viewing 1 replies (of 1 total)
  • The topic ‘How to filter the names of new groups during group creation?’ is closed to new replies.
Skip to toolbar