Skip to:
Content
Pages
Categories
Search
Top
Bottom

override function from my plugin


  • Nomi
    Participant

    @naumanahmed19

    can anyone guide me how can I override following function from my plugin. I know how to use add_action but I didn’t found add_action for this function in buddypress plugin. Its using do_action and I am not sure how to get it working

    function groups_screen_group_request_membership() {
    	global $bp;
    
    	if ( !is_user_logged_in() )
    		return false;
    
    	$bp = buddypress();
    
    	if ( 'private' != $bp->groups->current_group->status )
    		return false;
    
    	// If the user is already invited, accept invitation
    	if ( groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    		if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
    			bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
    		else
    			bp_core_add_message( __( 'There was an error accepting the group invitation, please try again.', 'buddypress' ), 'error' );
    		bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    	}
    
    	// If the user has submitted a request, send it.
    	if ( isset( $_POST['group-request-send']) ) {
    
    		// Check the nonce
    		if ( !check_admin_referer( 'groups_request_membership' ) )
    			return false;
    
    		if ( !groups_send_membership_request( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    			bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' );
    		} else {
    			bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
    		}
    		bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    	}
    
    	do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );
    
    	bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/home' ) );
    }

    its from bp-groups-screens.php

Viewing 2 replies - 1 through 2 (of 2 total)

  • r-a-y
    Keymaster

    @r-a-y

    It’s not clear what you are trying to achieve.

    Why would you want to override the group request validation function? What do you want to do?


    Nomi
    Participant

    @naumanahmed19

    I am trying to allow user to join group using enrollment key as you can see here.
    https://buddypress.org/support/topic/join-group-by-key/

    I got it working in core file but i have no idea how to implement in my plugin is there any other way?
    Here is my code

    
    if ($_POST['enrollment-key'] =='xxx'){
     				 groups_join_group($bp->groups->current_group->id , bp_loggedin_user_id() );
     				 bp_core_add_message( __('You have successfully joined this group.', 'buddypress' ) );
     			}else{
     				 groups_join_group($bp->groups->current_group->id , bp_loggedin_user_id() );
     				bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
     			}
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘override function from my plugin’ is closed to new replies.
Skip to toolbar