BP_Groups_Invite_Template::__construct( array $args = array() )

BP_Groups_Invite_Template constructor.

Description

Parameters

$args

(Optional)

Default value: array()

Source

File: bp-groups/classes/class-bp-groups-invite-template.php

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
public function __construct( $args = array() ) {
 
    // Backward compatibility with old method of passing arguments.
    if ( ! is_array( $args ) || func_num_args() > 1 ) {
        _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddyboss' ), __METHOD__, __FILE__ ) );
 
        $old_args_keys = array(
            0  => 'user_id',
            1  => 'group_id',
        );
 
        $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
    }
 
    $r = bp_parse_args( $args, array(
        'page'     => 1,
        'per_page' => 10,
        'page_arg' => 'invitepage',
        'user_id'  => bp_loggedin_user_id(),
        'group_id' => bp_get_current_group_id(),
    ), 'groups_invite_template' );
 
    $this->pag_arg  = sanitize_key( $r['page_arg'] );
    $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page']     );
    $this->pag_num  = bp_sanitize_pagination_arg( 'num',          $r['per_page'] );
 
    $iquery = new BP_Group_Member_Query( array(
        'group_id' => $r['group_id'],
        'type'     => 'first_joined',
        'per_page' => $this->pag_num,
        'page'     => $this->pag_page,
 
        // These filters ensure we get only pending invites.
        'is_confirmed' => false,
        'inviter_id'   => $r['user_id'],
    ) );
 
    $this->invite_data        = $iquery->results;
    $this->total_invite_count = $iquery->total_users;
    $this->invites            = array_values( wp_list_pluck( $this->invite_data, 'ID' ) );
    $this->invite_count       = count( $this->invites );
 
    // If per_page is set to 0 (show all results), don't generate
    // pag_links.
    if ( ! empty( $this->pag_num ) ) {
        $this->pag_links = paginate_links( array(
            'base'      => add_query_arg( $this->pag_arg, '%#%' ),
            'format'    => '',
            'total'     => ceil( $this->total_invite_count / $this->pag_num ),
            'current'   => $this->pag_page,
            'prev_text' => '←',
            'next_text' => '→',
            'mid_size'  => 1,
            'add_args'  => array(),
        ) );
    } else {
        $this->pag_links = '';
    }
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.