function process_group_request() { require_once WPPR_PLUGIN_DIR . '/models/group-model.php'; $model = new Group_Model(); check_ajax_referer('pr-home-actions', 'security'); if (isset($_POST['action']) && !empty($_POST['action']) && (isset($_POST['user_id']) && !empty($_POST['user_id'])) && (isset($_POST['group_id']) && !empty($_POST['group_id'])) && (isset($_POST['security']) && !empty($_POST['security'])) && (isset($_POST['status']) && !empty($_POST['status']))) { $model->member_id = intval($_POST['user_id']); //requesting member $model->user_id = get_current_user_id(); $model->group_id = intval($_POST['group_id']); $status_id = intval($_POST['status']); if (PR_Membership::is_valid_user($model->member_id) && $status_id) { if ($status_id == 1) { //Approve $result = $model->approve_group_join(); } else { $result = $model->disapprove_group_join(); } if ($result) { $result_code = 0; $result_msg = 'success'; } else { $result_code = 1; $result_msg = 'error'; } } } else { $result_code = 2; $result_msg = 'invalid connection request'; } wp_send_json(array('result_code' => $result_code, 'result_msg' => $result_msg, 'result_id' => $model->member_id)); wp_die(); }