Skip to:
Content
Pages
Categories
Search
Top
Bottom

Update Group name with Gravity Forms


  • hept27
    Participant

    @hept27

    I’m sure this is probably a round about, unorthodox thing to do, but essentially I’m using gravity forms to add/edit meta info for BP groups, just to keep everything on the front end in a way that I can control. One thing I can’t figure out how to to is an action to change the name of a given group. I’ve been able to edit the group type and a users group ID but not this. Essential I just need something that I can execute in a function which I will use with the gravity forms after submission hook.

    I looked at these functions:
    groups_details_updated
    groups_edit_base_group_details

    But couldn’t figure out how to parlay them into accomplishing what I’m attempting.

Viewing 1 replies (of 1 total)

  • hept27
    Participant

    @hept27

    Ask and ye shall receive. I figured it out, though I’m sure its not the cleanest solution:

    I created this function from the original “groups_edit_base_group_details” function

    	function bg_new_groups_edit_base_group_details( $group_id, $group_name, $group_desc, $notify_members ) {
    			global $bp;
    
    			if ( empty( $group_name ) || empty( $group_desc ) )
    				return false;
    
    			$group              = new BP_Groups_Group( $group_id );
    			$group->name        = $group_name;
    			$group->description = $group_desc;
    
    			if ( !$group->save() )
    				return false;
    
    			if ( $notify_members ) {
    				groups_notification_group_updated( $group_id, $group_id, false );
    			}
    
    			do_action( 'groups_details_updated', $group_id, $group_id, false );
    
    			return true;
    		}

    Then I put the following code in a gravity forms gform_after_submission action:

    				$group_id = 2;
    				$group_name = 'New NEw TEST';
    				$group_desc = 'testing description';
    				bg_new_groups_edit_base_group_details($group_id, $group_name, $group_desc, false); 

    This is the proof of concept the finished product will look a little different but function the same.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar