From a7de75de148b7260e03cf2b292e3c11470e44321 Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Fri, 4 Apr 2025 11:45:31 +0530
Subject: [PATCH 001/171] Protected API requests with the Authorization: Bearer
header. #137
---
.../rest-api/wpem-rest-authentication.php | 110 +++++++++++++-----
.../rest-api/wpem-rest-crud-controller.php | 28 +++++
wpem-rest-api-functions.php | 8 ++
wpem-rest-api.php | 9 +-
4 files changed, 124 insertions(+), 31 deletions(-)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 388547e..d3a0396 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -596,12 +596,12 @@ public function check_user_permissions( $result, $server, $request ) {
*/
public function register_routes() {
register_rest_route(
- 'wpem-auth',
+ 'wpem',
'/appkey' ,
array(
array(
- 'methods' => WP_REST_Server::READABLE,
- 'callback' => array( $this, 'perform_app_key_authentication' ),
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array( $this, 'perform_user_authentication' ),
'permission_callback' => '__return_true'
),
)
@@ -671,34 +671,86 @@ public function perform_login_authentication($request){
*
* @since 1.0.0
*/
- public function perform_app_key_authentication( $request ){
- global $wpdb;
- if( isset( $_GET['key'] ) && !empty( $_GET['key'] ) ){
- $app_key = sanitize_text_field( $_GET['key'] );
-
- $key_data = $wpdb->get_row(
- $wpdb->prepare(
- "
- SELECT key_id, app_key, user_id, permissions, consumer_key, consumer_secret, nonces, date_expires
- FROM {$wpdb->prefix}wpem_rest_api_keys
- WHERE app_key = %s
- ",
- $app_key
- )
- );
- if( !empty($key_data->date_expires ) && strtotime( $key_data->date_expires ) >= strtotime( date('Y-m-d H:i:s') ) ){
- $key_data->expiry = false;
- }else{
- $key_data->expiry = true;
- }
- if( empty( $key_data ) )
+ public function perform_user_authentication($request){
+ $params = $request->get_json_params();
+ $username = isset($params['username']) ? sanitize_text_field($params['username']) : '';
+ $password = isset($params['password']) ? $params['password'] : '';
+ $response = array();
+ if( !empty( $username ) && !empty($password)){
+ $user = wp_authenticate($username, $password);
+ if (is_wp_error($user)) {
return parent::prepare_error_for_response(401);
- $response_data = self::prepare_error_for_response( 200 );
- $response_data['data'] = array(
- 'user_info' => $key_data,
- );
- return wp_send_json($response_data);
+ } else {
+ global $wpdb;
+
+ $user_id = $user->ID;
+
+ $token = $this->wpem_generate_jwt_token($user->ID);
+
+ $key_data = $wpdb->get_row(
+ $wpdb->prepare(
+ "
+ SELECT *
+ FROM {$wpdb->prefix}wpem_rest_api_keys
+ WHERE user_id = %s
+ ",
+ $user_id
+ )
+ );
+
+ if( !empty($key_data->date_expires ) && strtotime( $key_data->date_expires ) >= strtotime( date('Y-m-d H:i:s') ) ){
+ $key_data->expiry = false;
+ } else {
+ $key_data->expiry = true;
+ }
+ $data = array(
+ 'token' => $token,
+ 'user' => array(
+ 'user_id' => $user->ID,
+ 'email' => $user->user_email,
+ ),
+ 'user_info' => $key_data,
+
+ );
+ if( !empty( $key_data ) )
+ $data['organizer_info'] = $key_data;
+ $response_data['data'] = $data;
+ return wp_send_json($response_data);
+ }
+ } else{
+ return parent::prepare_error_for_response(400);
}
}
+
+ /**
+ * This function will used to generate jwt token for individual user
+ * @since 1.0.9
+ */
+ public function wpem_generate_jwt_token($user_id) {
+ $user = get_userdata($user_id);
+ if (!$user) return false;
+
+ // Step 1: Create header & payload (Base64URL encoded)
+ $header = wpem_base64url_encode(json_encode(['alg' => 'HS256', 'typ' => 'JWT']));
+ $payload = wpem_base64url_encode(json_encode([
+ 'iss' => get_bloginfo('url'),
+ 'user' => [
+ 'id' => $user->ID,
+ 'username' => $user->user_login
+ ]
+ ]));
+
+ // Step 2: Generate signature
+ $signature = wpem_base64url_encode(hash_hmac('sha256', "$header.$payload", JWT_SECRET_KEY, true));
+
+ // Step 3: Remove non-alphanumeric characters (dots, dashes, underscores)
+ $clean_header = preg_replace('/[^A-Za-z0-9]/', '', $header);
+ $clean_payload = preg_replace('/[^A-Za-z0-9]/', '', $payload);
+ $clean_signature = preg_replace('/[^A-Za-z0-9]/', '', $signature);
+
+ // Step 4: Return final alphanumeric token
+ return $clean_header . $clean_payload . $clean_signature;
+ }
+
}
new WPEM_REST_Authentication();
\ No newline at end of file
diff --git a/includes/rest-api/wpem-rest-crud-controller.php b/includes/rest-api/wpem-rest-crud-controller.php
index 7b80211..9cc1a5d 100644
--- a/includes/rest-api/wpem-rest-crud-controller.php
+++ b/includes/rest-api/wpem-rest-crud-controller.php
@@ -738,4 +738,32 @@ public static function prepare_error_for_response( $code, $data = array()) {
return null; // Or handle the case where code 400 is not found
}
}
+
+ /**
+ * This function is used to verify token sent in api header
+ * @since 1.0.9
+ */
+ public function wpem_verify_jwt_token($token) {
+ $parts = explode('.', $token);
+ if (count($parts) !== 3) {
+ return false; // Invalid token format
+ }
+
+ list($header, $payload, $signature) = $parts;
+ $valid_signature = wpem_base64url_encode(hash_hmac('sha256', "$header.$payload", JWT_SECRET_KEY, true));
+
+ if ($signature !== $valid_signature) {
+ return false; // Invalid signature
+ }
+
+ $payload_data = json_decode(wpem_base64url_encode($payload), true);
+ $user = get_userdata($payload_data['user']['id']);
+
+ if (!$user || $user->user_login !== $payload_data['user']['username']) {
+ return false; // User does not exist or username changed
+ }
+
+ return $payload_data['user']; // Return user data
+ }
+
}
diff --git a/wpem-rest-api-functions.php b/wpem-rest-api-functions.php
index 07c2ac3..dd35a34 100644
--- a/wpem-rest-api-functions.php
+++ b/wpem-rest-api-functions.php
@@ -490,4 +490,12 @@ function check_wpem_plugin_activation($plugin_domain) {
}
}
}
+}
+
+/**
+ * This function will used to generate base64url_encode
+ * @since 1.0.9
+ */
+function wpem_base64url_encode($data) {
+ return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
\ No newline at end of file
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 3f44570..d065764 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -45,7 +45,12 @@ public function __construct() {
define( 'WPEM_REST_API_PLUGIN_DIR', untrailingslashit( plugin_dir_path(__FILE__ ) ) );
define( 'WPEM_REST_API_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path(__FILE__) ), basename(__FILE__) ) ) );
define( 'WPEM_PLUGIN_ACTIVATION_API_URL', 'https://wp-eventmanager.com/?wc-api=wpemstore_licensing_expire_license' );
-
+ if (!defined('JWT_SECRET_KEY')) {
+ define('JWT_SECRET_KEY', '9s59d4s9d49ed94sf46dsf74d96');
+ }
+ if (!defined('JWT_ALGO')) {
+ define('JWT_ALGO', 'HS256');
+ }
if( is_admin() ) {
include 'admin/wpem-rest-api-admin.php';
}
@@ -153,4 +158,4 @@ function wpem_rest_api_pre_check_before_installing_event_rest_api() {
return false;
}
}
-add_action( 'admin_notices', 'wpem_rest_api_pre_check_before_installing_event_rest_api' );
+add_action( 'admin_notices', 'wpem_rest_api_pre_check_before_installing_event_rest_api' );
\ No newline at end of file
From 1b8642894779d4798a68821614e6950a37b57e50 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 7 Apr 2025 18:26:57 +0530
Subject: [PATCH 002/171] Protected API requests with the Authorization: Bearer
header. #137
---
.../rest-api/wpem-rest-authentication.php | 28 ++---
.../rest-api/wpem-rest-crud-controller.php | 118 ++++++++----------
wpem-rest-api-functions.php | 9 ++
3 files changed, 70 insertions(+), 85 deletions(-)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index d3a0396..91ff127 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -707,10 +707,11 @@ public function perform_user_authentication($request){
'token' => $token,
'user' => array(
'user_id' => $user->ID,
- 'email' => $user->user_email,
- ),
- 'user_info' => $key_data,
-
+ 'user_email' => $user->user_email,
+ 'first_name' => $user->first_name,
+ 'last_name' => $user->last_name,
+ 'username' => $user->user_login,
+ )
);
if( !empty( $key_data ) )
$data['organizer_info'] = $key_data;
@@ -729,8 +730,8 @@ public function perform_user_authentication($request){
public function wpem_generate_jwt_token($user_id) {
$user = get_userdata($user_id);
if (!$user) return false;
-
- // Step 1: Create header & payload (Base64URL encoded)
+
+ // Header and payload
$header = wpem_base64url_encode(json_encode(['alg' => 'HS256', 'typ' => 'JWT']));
$payload = wpem_base64url_encode(json_encode([
'iss' => get_bloginfo('url'),
@@ -739,17 +740,12 @@ public function wpem_generate_jwt_token($user_id) {
'username' => $user->user_login
]
]));
-
- // Step 2: Generate signature
+
+ // Signature
$signature = wpem_base64url_encode(hash_hmac('sha256', "$header.$payload", JWT_SECRET_KEY, true));
-
- // Step 3: Remove non-alphanumeric characters (dots, dashes, underscores)
- $clean_header = preg_replace('/[^A-Za-z0-9]/', '', $header);
- $clean_payload = preg_replace('/[^A-Za-z0-9]/', '', $payload);
- $clean_signature = preg_replace('/[^A-Za-z0-9]/', '', $signature);
-
- // Step 4: Return final alphanumeric token
- return $clean_header . $clean_payload . $clean_signature;
+
+ // Return standard JWT format
+ return $header . '.' . $payload . '.' . $signature;
}
}
diff --git a/includes/rest-api/wpem-rest-crud-controller.php b/includes/rest-api/wpem-rest-crud-controller.php
index 9cc1a5d..0acccc4 100644
--- a/includes/rest-api/wpem-rest-crud-controller.php
+++ b/includes/rest-api/wpem-rest-crud-controller.php
@@ -652,53 +652,33 @@ public function wpem_check_authorized_user() {
// Get the authorization header
global $wpdb;
$headers = getallheaders();
- $auth_header = isset($headers['Authorization']) ? $headers['Authorization'] : '';
-
- if(empty($auth_header)) {
- $headers = apache_request_headers();
- // Ensure case insensitivity
- $auth_header = '';
- foreach ($headers as $key => $value) {
- if (strtolower($key) === 'authorization') {
- $auth_header = $value;
- break;
- }
- }
- }
+ $token = isset($headers['Authorization']) ? trim(str_replace('Bearer', '', $headers['Authorization'])) : '';
- // Check if authorization header is provided
- if (!$auth_header) {
+ if(empty($token)) {
return self::prepare_error_for_response(405);
}
- // Handle Basic Auth
- if (strpos($auth_header, 'Basic ') === 0) {
- $auth = base64_decode(substr($auth_header, 6));
- list($consumer_key, $consumer_secret) = explode(':', $auth);
- // Validate the credentials
- if ($consumer_key && $consumer_secret) {
- $user_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_rest_api_keys WHERE consumer_key = '$consumer_key' AND consumer_secret = '$consumer_secret'"));
- if($user_info){
- $user = get_userdata($user_info->user_id);
- if($user){
- $date_expires = date('Y-m-d', strtotime($user_info->date_expires));
- if( $user_info->permissions == 'write'){
- return self::prepare_error_for_response(203);
- } else if( $date_expires < date('Y-m-d') ){
- return self::prepare_error_for_response(503);
- } else {
- // Get ecosystem data
- $ecosystem_info = get_wpem_rest_api_ecosystem_info();
- if( !is_array( $ecosystem_info ) ) {
- return self::prepare_error_for_response(403, array("Plugin Name"=>$ecosystem_info));
- }
- return false;
- }
- } else {
- return self::prepare_error_for_response(405);
- }
+ $user_data = $this->wpem_validate_jwt_token($token);
+ if (!$user_data) {
+ return self::prepare_error_for_response(405);
+ }
+ $user = get_userdata($user_data['id']);
+
+ if($user){
+ $user_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = $user->ID "));
+ if($user_info){
+ $date_expires = date('Y-m-d', strtotime($user_info->date_expires));
+ if( $user_info->permissions == 'write'){
+ return self::prepare_error_for_response(203);
+ } else if( $date_expires < date('Y-m-d') ){
+ return self::prepare_error_for_response(503);
} else {
- return self::prepare_error_for_response(405);
+ // Get ecosystem data
+ $ecosystem_info = get_wpem_rest_api_ecosystem_info();
+ if( !is_array( $ecosystem_info ) ) {
+ return self::prepare_error_for_response(403, array("Plugin Name"=>$ecosystem_info));
+ }
+ return false;
}
} else {
return self::prepare_error_for_response(405);
@@ -707,6 +687,33 @@ public function wpem_check_authorized_user() {
return self::prepare_error_for_response(405);
}
}
+
+ /**
+ * This function is used to verify token sent in api header
+ * @since 1.0.9
+ */
+ public function wpem_validate_jwt_token($token) {
+ // Extract the JWT parts
+ $parts = explode('.', $token);
+ if (count($parts) !== 3) {
+ return false;
+ }
+
+ list($encodedHeader, $encodedPayload, $encodedSignature) = $parts;
+
+ $payload_json = wpem_base64url_decode($encodedPayload);
+ $payload = json_decode($payload_json, true);
+
+ // Re-generate signature
+ $signature = hash_hmac('sha256', "$encodedHeader.$encodedPayload", JWT_SECRET_KEY, true);
+ $expected_signature = wpem_base64url_encode(hash_hmac('sha256', "$encodedHeader.$encodedPayload", JWT_SECRET_KEY, true));
+
+ if ($expected_signature === $encodedSignature) {
+ $payload = json_decode(wpem_base64url_decode($encodedPayload), true);
+ return $payload['user'];
+ }
+ return false;
+ }
/**
* Prepares the error for the REST response.
@@ -738,32 +745,5 @@ public static function prepare_error_for_response( $code, $data = array()) {
return null; // Or handle the case where code 400 is not found
}
}
-
- /**
- * This function is used to verify token sent in api header
- * @since 1.0.9
- */
- public function wpem_verify_jwt_token($token) {
- $parts = explode('.', $token);
- if (count($parts) !== 3) {
- return false; // Invalid token format
- }
-
- list($header, $payload, $signature) = $parts;
- $valid_signature = wpem_base64url_encode(hash_hmac('sha256', "$header.$payload", JWT_SECRET_KEY, true));
-
- if ($signature !== $valid_signature) {
- return false; // Invalid signature
- }
-
- $payload_data = json_decode(wpem_base64url_encode($payload), true);
- $user = get_userdata($payload_data['user']['id']);
-
- if (!$user || $user->user_login !== $payload_data['user']['username']) {
- return false; // User does not exist or username changed
- }
-
- return $payload_data['user']; // Return user data
- }
}
diff --git a/wpem-rest-api-functions.php b/wpem-rest-api-functions.php
index dd35a34..aadbe87 100644
--- a/wpem-rest-api-functions.php
+++ b/wpem-rest-api-functions.php
@@ -498,4 +498,13 @@ function check_wpem_plugin_activation($plugin_domain) {
*/
function wpem_base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
+}
+
+function wpem_base64url_decode($data) {
+ $remainder = strlen($data) % 4;
+ if ($remainder) {
+ $padlen = 4 - $remainder;
+ $data .= str_repeat('=', $padlen);
+ }
+ return base64_decode(strtr($data, '-_', '+/'));
}
\ No newline at end of file
From 53f794f15cec2a37ca422828b5d2adc3cf43e935 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 7 Apr 2025 18:30:25 +0530
Subject: [PATCH 003/171] Protected API requests with the Authorization: Bearer
header. #137
---
includes/rest-api/wpem-rest-authentication.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 91ff127..5ae9b45 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -597,7 +597,7 @@ public function check_user_permissions( $result, $server, $request ) {
public function register_routes() {
register_rest_route(
'wpem',
- '/appkey' ,
+ '/applogin' ,
array(
array(
'methods' => WP_REST_Server::CREATABLE,
From c575dbe3fb4aec58a17d119d341349fb2d2a5329 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 7 Apr 2025 18:34:23 +0530
Subject: [PATCH 004/171] Protected API requests with the Authorization: Bearer
header. #137
---
includes/rest-api/wpem-rest-authentication.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 5ae9b45..68eac54 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -659,7 +659,7 @@ public function perform_login_authentication($request){
$response_data['data'] = array(
'user_info' => $key_data,
);
- return wp_send_json($response_data);
+ return $response_data;
}
} else{
return parent::prepare_error_for_response(400);
@@ -715,8 +715,9 @@ public function perform_user_authentication($request){
);
if( !empty( $key_data ) )
$data['organizer_info'] = $key_data;
+ $response_data = parent::prepare_error_for_response(200);
$response_data['data'] = $data;
- return wp_send_json($response_data);
+ return $response_data;
}
} else{
return parent::prepare_error_for_response(400);
From 53f0e4b56771418f8fff49662ce7cb462e000d77 Mon Sep 17 00:00:00 2001
From: Rita
Date: Tue, 8 Apr 2025 12:12:12 +0530
Subject: [PATCH 005/171] Protected API requests with the Authorization: Bearer
header. #137
---
includes/rest-api/debug.log | 118 ++++++++++++++++++
.../rest-api/wpem-rest-authentication.php | 4 +-
2 files changed, 120 insertions(+), 2 deletions(-)
create mode 100644 includes/rest-api/debug.log
diff --git a/includes/rest-api/debug.log b/includes/rest-api/debug.log
new file mode 100644
index 0000000..94a529b
--- /dev/null
+++ b/includes/rest-api/debug.log
@@ -0,0 +1,118 @@
+[08-Apr-2025 06:25:18 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:18 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:18 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:19 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:20 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:21 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:21 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:21 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function order was called incorrectly . Subscription properties should not be accessed directly as WooCommerce 3.0 no longer supports direct property access. Use WC_Subscription::get_parent() instead. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_details_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_details_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-details.php'), WC_Subscription->__get, wcs_doing_it_wrong, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 2.2.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function id was called incorrectly . Order properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_details_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_details_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-details.php'), WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function order was called incorrectly . Subscription properties should not be accessed directly as WooCommerce 3.0 no longer supports direct property access. Use WC_Subscription::get_parent() instead. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_totals_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals.php'), do_action('woocommerce_subscription_totals'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_table_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php'), WC_Subscription->__get, wcs_doing_it_wrong, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 2.2.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function id was called incorrectly . Order properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_totals_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals.php'), do_action('woocommerce_subscription_totals'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_table_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php'), WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_totals_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals.php'), do_action('woocommerce_subscription_totals'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_table_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php'), WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:22 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:23 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:23 UTC] PHP Fatal error: Uncaught Error: Class "WCPBC_Update_Exchange_Rates" not found in /www/wpeventmanager_673/public/wp-content/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php:224
+Stack trace:
+#0 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include()
+#1 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php(173): wc_get_template('myaccount/subsc...', Array, '', '/www/wpeventman...')
+#2 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): WCS_Template_Loader::get_subscription_totals_table_template(Object(WC_Subscription), false, Array, true)
+#3 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
+#4 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
+#5 /www/wpeventmanager_673/public/wp-content/themes/wpemstore/woocommerce/myaccount/subscription-totals.php(25): do_action('woocommerce_sub...', Object(WC_Subscription), false, Array, true)
+#6 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include('/www/wpeventman...')
+#7 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php(127): wc_get_template('myaccount/subsc...', Array, '', '/www/wpeventman...')
+#8 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): WCS_Template_Loader::get_subscription_totals_template(Object(WC_Subscription))
+#9 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
+#10 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
+#11 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php(30): do_action('woocommerce_sub...', Object(WC_Subscription))
+#12 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include('/www/wpeventman...')
+#13 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php(107): wc_get_template('myaccount/view-...', Array, '', '/www/wpeventman...')
+#14 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): WCS_Template_Loader::get_view_subscription_template('70320')
+#15 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
+#16 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
+#17 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php(3448): do_action('woocommerce_acc...', '70320')
+#18 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): woocommerce_account_content('')
+#19 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
+#20 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
+#21 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/templates/myaccount/my-account.php(34): do_action('woocommerce_acc...')
+#22 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include('/www/wpeventman...')
+#23 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php(125): wc_get_template('myaccount/my-ac...', Array)
+#24 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php(57): WC_Shortcode_My_Account::my_account(Array)
+#25 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(75): WC_Shortcode_My_Account::output(Array)
+#26 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(118): WC_Shortcodes::shortcode_wrapper(Array, Array)
+#27 /www/wpeventmanager_673/public/wp-includes/shortcodes.php(434): WC_Shortcodes::my_account(Array, '', 'woocommerce_my_...')
+#28 [internal function]: do_shortcode_tag(Array)
+#29 /www/wpeventmanager_673/public/wp-includes/shortcodes.php(273): preg_replace_callback('/\\[(\\[?)(woocom...', 'do_shortcode_ta...', '[woocommerce_my...')
+#30 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): do_shortcode('[woocommerce_my...')
+#31 /www/wpeventmanager_673/public/wp-includes/plugin.php(205): WP_Hook->apply_filters('[woocommerce_my...', Array)
+#32 /www/wpeventmanager_673/public/wp-includes/post-template.php(256): apply_filters('the_content', '[woocommerce_my...')
+#33 /www/wpeventmanager_673/public/wp-content/themes/wpemstore/page.php(47): the_content()
+#34 /www/wpeventmanager_673/public/wp-includes/template-loader.php(106): include('/www/wpeventman...')
+#35 /www/wpeventmanager_673/public/wp-blog-header.php(19): require_once('/www/wpeventman...')
+#36 /www/wpeventmanager_673/public/index.php(17): require('/www/wpeventman...')
+#37 {main}
+ thrown in /www/wpeventmanager_673/public/wp-content/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php on line 224
+[08-Apr-2025 06:25:23 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:23 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:24 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:24 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:24 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:25 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:25 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:26 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:26 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:26 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:27 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:28 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
+[08-Apr-2025 06:25:30 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:30 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:30 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:31 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Product_Variable_Subscription->__get, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:32 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Product_Variable_Subscription->__get, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:34 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:35 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:36 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:36 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:36 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:36 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Product_Variable_Subscription->__get, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:37 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:37 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:37 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
+[08-Apr-2025 06:25:38 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 68eac54..2227bde 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -626,7 +626,7 @@ public function register_routes() {
*/
public function perform_login_authentication($request){
$params = $request->get_json_params();
- $username = isset($params['username']) ? sanitize_text_field($params['username']) : '';
+ $username = isset($params['username']) ? trim($params['username']) : '';
$password = isset($params['password']) ? $params['password'] : '';
$response = array();
if( !empty( $username ) && !empty($password)){
@@ -673,7 +673,7 @@ public function perform_login_authentication($request){
*/
public function perform_user_authentication($request){
$params = $request->get_json_params();
- $username = isset($params['username']) ? sanitize_text_field($params['username']) : '';
+ $username = isset($params['username']) ? trim($params['username']) : '';
$password = isset($params['password']) ? $params['password'] : '';
$response = array();
if( !empty( $username ) && !empty($password)){
From 08387737ce984875437fe47f0b167f09c814d21a Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Thu, 1 May 2025 16:20:03 +0530
Subject: [PATCH 006/171] Improve api response time to make apis faster #149
---
includes/rest-api/debug.log | 118 ------------------
.../rest-api/wpem-rest-crud-controller.php | 5 -
2 files changed, 123 deletions(-)
delete mode 100644 includes/rest-api/debug.log
diff --git a/includes/rest-api/debug.log b/includes/rest-api/debug.log
deleted file mode 100644
index 94a529b..0000000
--- a/includes/rest-api/debug.log
+++ /dev/null
@@ -1,118 +0,0 @@
-[08-Apr-2025 06:25:18 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:18 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:18 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:19 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:19 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:20 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:20 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:21 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:21 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:21 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function order was called incorrectly . Subscription properties should not be accessed directly as WooCommerce 3.0 no longer supports direct property access. Use WC_Subscription::get_parent() instead. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_details_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_details_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-details.php'), WC_Subscription->__get, wcs_doing_it_wrong, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 2.2.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function id was called incorrectly . Order properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_details_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_details_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-details.php'), WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function order was called incorrectly . Subscription properties should not be accessed directly as WooCommerce 3.0 no longer supports direct property access. Use WC_Subscription::get_parent() instead. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_totals_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals.php'), do_action('woocommerce_subscription_totals'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_table_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php'), WC_Subscription->__get, wcs_doing_it_wrong, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 2.2.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function id was called incorrectly . Order properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_totals_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals.php'), do_action('woocommerce_subscription_totals'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_table_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php'), WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, WC_Shortcodes::my_account, WC_Shortcodes::shortcode_wrapper, WC_Shortcode_My_Account::output, WC_Shortcode_My_Account::my_account, wc_get_template, include('/plugins/woocommerce/templates/myaccount/my-account.php'), do_action('woocommerce_account_content'), WP_Hook->do_action, WP_Hook->apply_filters, woocommerce_account_content, do_action('woocommerce_account_view-subscription_endpoint'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_view_subscription_template, wc_get_template, include('/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php'), do_action('woocommerce_subscription_totals_table'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals.php'), do_action('woocommerce_subscription_totals'), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Template_Loader::get_subscription_totals_table_template, wc_get_template, include('/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php'), WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:22 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:23 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:23 UTC] PHP Fatal error: Uncaught Error: Class "WCPBC_Update_Exchange_Rates" not found in /www/wpeventmanager_673/public/wp-content/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php:224
-Stack trace:
-#0 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include()
-#1 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php(173): wc_get_template('myaccount/subsc...', Array, '', '/www/wpeventman...')
-#2 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): WCS_Template_Loader::get_subscription_totals_table_template(Object(WC_Subscription), false, Array, true)
-#3 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
-#4 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
-#5 /www/wpeventmanager_673/public/wp-content/themes/wpemstore/woocommerce/myaccount/subscription-totals.php(25): do_action('woocommerce_sub...', Object(WC_Subscription), false, Array, true)
-#6 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include('/www/wpeventman...')
-#7 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php(127): wc_get_template('myaccount/subsc...', Array, '', '/www/wpeventman...')
-#8 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): WCS_Template_Loader::get_subscription_totals_template(Object(WC_Subscription))
-#9 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
-#10 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
-#11 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/view-subscription.php(30): do_action('woocommerce_sub...', Object(WC_Subscription))
-#12 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include('/www/wpeventman...')
-#13 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wcs-template-loader.php(107): wc_get_template('myaccount/view-...', Array, '', '/www/wpeventman...')
-#14 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): WCS_Template_Loader::get_view_subscription_template('70320')
-#15 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
-#16 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
-#17 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php(3448): do_action('woocommerce_acc...', '70320')
-#18 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): woocommerce_account_content('')
-#19 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
-#20 /www/wpeventmanager_673/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
-#21 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/templates/myaccount/my-account.php(34): do_action('woocommerce_acc...')
-#22 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php(346): include('/www/wpeventman...')
-#23 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php(125): wc_get_template('myaccount/my-ac...', Array)
-#24 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php(57): WC_Shortcode_My_Account::my_account(Array)
-#25 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(75): WC_Shortcode_My_Account::output(Array)
-#26 /www/wpeventmanager_673/public/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(118): WC_Shortcodes::shortcode_wrapper(Array, Array)
-#27 /www/wpeventmanager_673/public/wp-includes/shortcodes.php(434): WC_Shortcodes::my_account(Array, '', 'woocommerce_my_...')
-#28 [internal function]: do_shortcode_tag(Array)
-#29 /www/wpeventmanager_673/public/wp-includes/shortcodes.php(273): preg_replace_callback('/\\[(\\[?)(woocom...', 'do_shortcode_ta...', '[woocommerce_my...')
-#30 /www/wpeventmanager_673/public/wp-includes/class-wp-hook.php(324): do_shortcode('[woocommerce_my...')
-#31 /www/wpeventmanager_673/public/wp-includes/plugin.php(205): WP_Hook->apply_filters('[woocommerce_my...', Array)
-#32 /www/wpeventmanager_673/public/wp-includes/post-template.php(256): apply_filters('the_content', '[woocommerce_my...')
-#33 /www/wpeventmanager_673/public/wp-content/themes/wpemstore/page.php(47): the_content()
-#34 /www/wpeventmanager_673/public/wp-includes/template-loader.php(106): include('/www/wpeventman...')
-#35 /www/wpeventmanager_673/public/wp-blog-header.php(19): require_once('/www/wpeventman...')
-#36 /www/wpeventmanager_673/public/index.php(17): require('/www/wpeventman...')
-#37 {main}
- thrown in /www/wpeventmanager_673/public/wp-content/themes/wpemstore/woocommerce/myaccount/subscription-totals-table.php on line 224
-[08-Apr-2025 06:25:23 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:23 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:24 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:24 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:24 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:25 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:25 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:25 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:26 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:26 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:26 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:27 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:27 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:28 UTC] PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /www/wpeventmanager_673/public/wp-content/plugins/wpemstore-licensing/includes/markdown.php on line 934
-[08-Apr-2025 06:25:30 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:30 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:30 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:31 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Product_Variable_Subscription->__get, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:31 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:32 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Product_Variable_Subscription->__get, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:34 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:34 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:35 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:36 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:36 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:36 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:36 UTC] PHP Notice: Function id was called incorrectly . Product properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/wpemstore/woocommerce/single-product.php'), wc_get_template_part, load_template, require('/themes/wpemstore/woocommerce/content-single-product.php'), WC_Product_Variable_Subscription->__get, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:37 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:37 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the better-click-to-tweet
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:37 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the woocommerce-paypal-payments
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
-[08-Apr-2025 06:25:38 UTC] PHP Notice: Function _load_textdomain_just_in_time was called incorrectly . Translation loading for the cf7-zohocrm-integration
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /www/wpeventmanager_673/public/wp-includes/functions.php on line 6114
diff --git a/includes/rest-api/wpem-rest-crud-controller.php b/includes/rest-api/wpem-rest-crud-controller.php
index 0acccc4..2facee6 100644
--- a/includes/rest-api/wpem-rest-crud-controller.php
+++ b/includes/rest-api/wpem-rest-crud-controller.php
@@ -673,11 +673,6 @@ public function wpem_check_authorized_user() {
} else if( $date_expires < date('Y-m-d') ){
return self::prepare_error_for_response(503);
} else {
- // Get ecosystem data
- $ecosystem_info = get_wpem_rest_api_ecosystem_info();
- if( !is_array( $ecosystem_info ) ) {
- return self::prepare_error_for_response(403, array("Plugin Name"=>$ecosystem_info));
- }
return false;
}
} else {
From cacda3c4eeaf6452d2d3f582548ac01f450d42c8 Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Fri, 2 May 2025 10:23:45 +0530
Subject: [PATCH 007/171] Version 1.0.9 improvements #150
---
readme.txt | 12 ++++++++++--
wpem-rest-api.php | 4 ++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/readme.txt b/readme.txt
index 214cc2b..3373bfa 100755
--- a/readme.txt
+++ b/readme.txt
@@ -4,8 +4,8 @@ Contributors: wpeventmanager,ashokdudhat,krinay
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=55FRYATTFLA5N
Tags: event manager, Event, events, event manager api , listings
Requires at least: 6.0.1
-Tested up to: 6.7
-Stable tag: 1.0.8
+Tested up to: 6.8
+Stable tag: 1.0.9
Requires PHP: 8.0.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -119,6 +119,14 @@ If you wish to be notified of new postings on your site you can use a plugin suc
== Changelog ==
+= 1.0.9 [ 02nd May 2025 ] =
+
+Fixed: API response time is improved to make APIs faster
+Fixed: API requests are now protected with authorization
+Fixed: The data loading time in the attendee section became faster
+Fixed: The manual check-in process of attendees became faster
+Fixed: Initiated multiple bug fixes and code improvements
+
= 1.0.8 [ 27th March 2025 ] =
Fixed : Password with some special character, user not able to loggedin in app.
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index d065764..58536df 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -9,7 +9,7 @@
*
* Text Domain: wpem-rest-api
* Domain Path: /languages
-* Version: 1.0.8
+* Version: 1.0.9
* Since: 1.0.0
*
* Requires WordPress Version at least: 6.0.1
@@ -40,7 +40,7 @@ public function __construct() {
}
// Define constants
- define( 'WPEM_REST_API_VERSION', '1.0.8' );
+ define( 'WPEM_REST_API_VERSION', '1.0.9' );
define( 'WPEM_REST_API_FILE', __FILE__ );
define( 'WPEM_REST_API_PLUGIN_DIR', untrailingslashit( plugin_dir_path(__FILE__ ) ) );
define( 'WPEM_REST_API_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path(__FILE__) ), basename(__FILE__) ) ) );
From 6a07239b2dc3e90cca9d09269abb2de9064ad0fb Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Mon, 5 May 2025 14:37:52 +0530
Subject: [PATCH 008/171] In application the event time should be show based on
time format selection #153
---
includes/rest-api/wpem-rest-events-controller.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/includes/rest-api/wpem-rest-events-controller.php b/includes/rest-api/wpem-rest-events-controller.php
index bb4702b..505928a 100644
--- a/includes/rest-api/wpem-rest-events-controller.php
+++ b/includes/rest-api/wpem-rest-events-controller.php
@@ -305,7 +305,11 @@ protected function get_images( $event ) {
protected function get_event_data( $event, $context = 'view' ) {
$meta_data = get_post_meta( $event->ID );
foreach( $meta_data as $key => $value ) {
- $meta_data[$key]= get_post_meta( $event->ID, $key, true );
+ if('_event_start_time' == $key || '_event_end_time' == $key ) {
+ $time_format = WP_Event_Manager_Date_Time::get_timepicker_format();
+ $meta_data[$key] = esc_attr(date_i18n($time_format, strtotime(get_post_meta( $event->ID, $key, true ))));
+ } else
+ $meta_data[$key]= get_post_meta( $event->ID, $key, true );
}
$data = array(
'id' => $event->ID,
From 9cf6f99670689d8fc43c31c546413b64aece8104 Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Fri, 9 May 2025 08:55:00 +0530
Subject: [PATCH 009/171] all events are shown even from other organizers #155
---
.../rest-api/wpem-rest-crud-controller.php | 4 +-
wpem-rest-api-functions.php | 70 ++++---------------
2 files changed, 14 insertions(+), 60 deletions(-)
diff --git a/includes/rest-api/wpem-rest-crud-controller.php b/includes/rest-api/wpem-rest-crud-controller.php
index 2facee6..6f0ba57 100644
--- a/includes/rest-api/wpem-rest-crud-controller.php
+++ b/includes/rest-api/wpem-rest-crud-controller.php
@@ -658,7 +658,7 @@ public function wpem_check_authorized_user() {
return self::prepare_error_for_response(405);
}
- $user_data = $this->wpem_validate_jwt_token($token);
+ $user_data = self::wpem_validate_jwt_token($token);
if (!$user_data) {
return self::prepare_error_for_response(405);
}
@@ -687,7 +687,7 @@ public function wpem_check_authorized_user() {
* This function is used to verify token sent in api header
* @since 1.0.9
*/
- public function wpem_validate_jwt_token($token) {
+ public static function wpem_validate_jwt_token($token) {
// Extract the JWT parts
$parts = explode('.', $token);
if (count($parts) !== 3) {
diff --git a/wpem-rest-api-functions.php b/wpem-rest-api-functions.php
index aadbe87..f240a41 100644
--- a/wpem-rest-api-functions.php
+++ b/wpem-rest-api-functions.php
@@ -393,73 +393,27 @@ function get_wpem_event_users() {
}
}
-if( !function_exists( 'wpem_rest_check_user_data' ) ) {
-
+if( !function_exists( 'wpem_rest_get_current_user_id' ) ) {
/**
- * This function is used to check user information
+ * This function is used to check user is exist or not.
+ * @since 1.0.1
*/
- function wpem_rest_check_user_data() {
+ function wpem_rest_get_current_user_id(){
// Get the authorization header
- global $wpdb;
$headers = getallheaders();
- $auth_header = isset($headers['Authorization']) ? $headers['Authorization'] : '';
-
- if(empty($auth_header)) {
- $headers = apache_request_headers();
- // Ensure case insensitivity
- $auth_header = '';
- foreach ($headers as $key => $value) {
- if (strtolower($key) === 'authorization') {
- $auth_header = $value;
- break;
- }
- }
- }
- // Check if authorization header is provided
- if (!$auth_header) {
+ $token = isset($headers['Authorization']) ? trim(str_replace('Bearer', '', $headers['Authorization'])) : '';
+
+ if(empty($token)) {
return WPEM_REST_CRUD_Controller::prepare_error_for_response(401);
}
- // Handle Basic Auth
- if (strpos($auth_header, 'Basic ') === 0) {
- $auth = base64_decode(substr($auth_header, 6));
- list($consumer_key, $consumer_secret) = explode(':', $auth);
- // Validate the credentials
- if ($consumer_key && $consumer_secret) {
- $app_key = $wpdb->get_var($wpdb->prepare("SELECT app_key FROM {$wpdb->prefix}wpem_rest_api_keys WHERE consumer_key = '$consumer_key'"));
- if($app_key){
- return $app_key;
- } else{
- return true;
- }
- } else {
- return true;
- }
- } else {
- return true;
+ $user_data = WPEM_REST_CRUD_Controller::wpem_validate_jwt_token($token);
+ if (!$user_data) {
+ return WPEM_REST_CRUD_Controller::prepare_error_for_response(405);
}
- }
-}
-if( !function_exists( 'wpem_rest_get_current_user_id' ) ) {
- /**
- * This function is used to check user is exist or not.
- * @since 1.0.1
- */
- function wpem_rest_get_current_user_id(){
- global $wpdb;
- $get_user_id = wpem_rest_check_user_data();
- // Check if $get_userid is a WP_REST_Response object
- if (is_a($get_user_id, 'WP_REST_Response')) {
- // Extract the data from the response
- $get_user_id = $get_user_id->get_data();
- }
- $user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$wpdb->prefix}wpem_rest_api_keys WHERE app_key = '$get_user_id'"));
- if ($user_id) {
- return $user_id;
- } else {
- return false;
- }
+ $user_id = $user_data['id'];
+ return $user_id;
}
}
From 568647dab84f75ae5fa2029e47ca8a3b8bdf591b Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Fri, 9 May 2025 09:12:42 +0530
Subject: [PATCH 010/171] version update 1.0.10 #156
---
readme.txt | 7 ++++++-
wpem-rest-api.php | 4 ++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/readme.txt b/readme.txt
index 3373bfa..936617f 100755
--- a/readme.txt
+++ b/readme.txt
@@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: event manager, Event, events, event manager api , listings
Requires at least: 6.0.1
Tested up to: 6.8
-Stable tag: 1.0.9
+Stable tag: 1.0.10
Requires PHP: 8.0.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -119,6 +119,11 @@ If you wish to be notified of new postings on your site you can use a plugin suc
== Changelog ==
+
+= 1.0.10 [ 09th May 2025 ] =
+
+Fixed: All events are shown even from other organizers
+
= 1.0.9 [ 02nd May 2025 ] =
Fixed: API response time is improved to make APIs faster
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 58536df..3fcc98f 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -9,7 +9,7 @@
*
* Text Domain: wpem-rest-api
* Domain Path: /languages
-* Version: 1.0.9
+* Version: 1.0.10
* Since: 1.0.0
*
* Requires WordPress Version at least: 6.0.1
@@ -40,7 +40,7 @@ public function __construct() {
}
// Define constants
- define( 'WPEM_REST_API_VERSION', '1.0.9' );
+ define( 'WPEM_REST_API_VERSION', '1.0.10' );
define( 'WPEM_REST_API_FILE', __FILE__ );
define( 'WPEM_REST_API_PLUGIN_DIR', untrailingslashit( plugin_dir_path(__FILE__ ) ) );
define( 'WPEM_REST_API_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path(__FILE__) ), basename(__FILE__) ) ) );
From 61af194497008921e5a312ce831c13bcfd91d822 Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Fri, 9 May 2025 11:20:12 +0530
Subject: [PATCH 011/171] all events are shown even from other organizers #155
---
includes/rest-api/wpem-rest-events-controller.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/rest-api/wpem-rest-events-controller.php b/includes/rest-api/wpem-rest-events-controller.php
index 505928a..63b47c5 100644
--- a/includes/rest-api/wpem-rest-events-controller.php
+++ b/includes/rest-api/wpem-rest-events-controller.php
@@ -237,7 +237,7 @@ protected function prepare_objects_query( $request ) {
$args['tax_query'] = $tax_query; // WPCS: slow query ok.
}
- $args['author'] = get_current_user_id();
+ $args['author'] = wpem_rest_get_current_user_id();
$args['post_type'] = $this->post_type;
return $args;
From 6960c179739227ec2b2bf5dfa8e299cc969e0678 Mon Sep 17 00:00:00 2001
From: Rita
Date: Tue, 20 May 2025 11:24:27 +0530
Subject: [PATCH 012/171] Login API Changes #158
---
.../rest-api/wpem-rest-authentication.php | 35 ++++++++++---------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 2227bde..3af61eb 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -687,22 +687,6 @@ public function perform_user_authentication($request){
$token = $this->wpem_generate_jwt_token($user->ID);
- $key_data = $wpdb->get_row(
- $wpdb->prepare(
- "
- SELECT *
- FROM {$wpdb->prefix}wpem_rest_api_keys
- WHERE user_id = %s
- ",
- $user_id
- )
- );
-
- if( !empty($key_data->date_expires ) && strtotime( $key_data->date_expires ) >= strtotime( date('Y-m-d H:i:s') ) ){
- $key_data->expiry = false;
- } else {
- $key_data->expiry = true;
- }
$data = array(
'token' => $token,
'user' => array(
@@ -713,8 +697,25 @@ public function perform_user_authentication($request){
'username' => $user->user_login,
)
);
- if( !empty( $key_data ) )
+
+ $key_data = $wpdb->get_row(
+ $wpdb->prepare(
+ "
+ SELECT *
+ FROM {$wpdb->prefix}wpem_rest_api_keys
+ WHERE user_id = %s
+ ",
+ $user_id
+ )
+ );
+ if( !empty( $key_data ) ) {
+ if( !empty($key_data->date_expires ) && strtotime( $key_data->date_expires ) >= strtotime( date('Y-m-d H:i:s') ) ){
+ $key_data->expiry = false;
+ } else {
+ $key_data->expiry = true;
+ }
$data['organizer_info'] = $key_data;
+ }
$response_data = parent::prepare_error_for_response(200);
$response_data['data'] = $data;
return $response_data;
From 92a2d944215dd2c9f3a2268d6b729e8cbb53f407 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 22 May 2025 16:21:21 +0530
Subject: [PATCH 013/171] #136 Need APIs for profile edit/update for attendee
for match making Feature
---
.../wpem-rest-edit-matchmaking-profile.php | 102 ++++++++++++++++++
.../wpem-rest-matchmaking-profile.php | 90 ++++++++++++++++
wpem-rest-api.php | 4 +
3 files changed, 196 insertions(+)
create mode 100644 includes/rest-api/wpem-rest-edit-matchmaking-profile.php
create mode 100644 includes/rest-api/wpem-rest-matchmaking-profile.php
diff --git a/includes/rest-api/wpem-rest-edit-matchmaking-profile.php b/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
new file mode 100644
index 0000000..d10f882
--- /dev/null
+++ b/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
@@ -0,0 +1,102 @@
+namespace,
+ '/' . $this->rest_base . '/update',
+ array(
+ 'methods' => WP_REST_Server::EDITABLE, // PUT/PATCH/POST
+ 'callback' => array($this, 'update_attendee_profile'),
+ 'permission_callback' => '__return_true', // For testing, allow all (you should restrict this in production)
+ 'args' => array(
+ 'user_id' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ ),
+ ),
+ )
+ );
+ }
+
+ public function update_attendee_profile($request) {
+ global $wpdb;
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $user_id = $request->get_param('user_id');
+
+ // Check if the user exists in the table
+ $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
+ if (!$existing) {
+ return new WP_REST_Response(array(
+ 'success' => false,
+ 'message' => 'Attendee not found.',
+ ), 404);
+ }
+
+ // Get all possible fields from request
+ $fields = array(
+ 'profile_photo',
+ 'profession',
+ 'experience',
+ 'company_name',
+ 'country',
+ 'city',
+ 'about',
+ 'skills',
+ 'interests',
+ 'organization_name',
+ 'organization_logo',
+ 'organization_city',
+ 'organization_country',
+ 'organization_description',
+ 'message_notification',
+ 'approve_profile_status',
+ );
+
+ $data = [];
+ foreach ($fields as $field) {
+ if ($request->get_param($field) !== null) {
+ $data[$field] = sanitize_text_field($request->get_param($field));
+ }
+ }
+
+ if (empty($data)) {
+ return new WP_REST_Response(array(
+ 'success' => false,
+ 'message' => 'No data provided to update.',
+ ), 400);
+ }
+
+ $updated = $wpdb->update($table, $data, array('user_id' => $user_id));
+
+ if ($updated === false) {
+ return new WP_REST_Response(array(
+ 'success' => false,
+ 'message' => 'Failed to update attendee profile.',
+ ), 500);
+ }
+
+ return new WP_REST_Response(array(
+ 'success' => true,
+ 'message' => 'Attendee profile updated successfully.',
+ ), 200);
+ }
+}
+
+new WPEM_REST_Attendee_Profile_Update_Controller();
+
+
+?>
\ No newline at end of file
diff --git a/includes/rest-api/wpem-rest-matchmaking-profile.php b/includes/rest-api/wpem-rest-matchmaking-profile.php
new file mode 100644
index 0000000..98a6af4
--- /dev/null
+++ b/includes/rest-api/wpem-rest-matchmaking-profile.php
@@ -0,0 +1,90 @@
+namespace,
+ '/' . $this->rest_base,
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'get_attendee_profile'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'attendeeId' => array(
+ 'required' => false,
+ 'type' => 'integer',
+ )
+ ),
+ )
+ );
+ }
+
+ public function get_attendee_profile($request) {
+ global $wpdb;
+ $attendee_id = $request->get_param('attendeeId');
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ if ($attendee_id) {
+ // Fetch single attendee
+ $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $attendee_id), ARRAY_A);
+
+ if (!$data) {
+ return new WP_REST_Response(array(
+ 'success' => false,
+ 'message' => 'Attendee not found.'
+ ), 404);
+ }
+
+ $profile = $this->format_profile_data($data);
+
+ return new WP_REST_Response(array(
+ 'success' => true,
+ 'message' => 'Profile retrieved successfully.',
+ 'data' => $profile
+ ), 200);
+ } else {
+ // Fetch all attendees
+ $results = $wpdb->get_results("SELECT * FROM $table", ARRAY_A);
+
+ $profiles = array_map(array($this, 'format_profile_data'), $results);
+
+ return new WP_REST_Response(array(
+ 'success' => true,
+ 'message' => 'All attendee profiles retrieved successfully.',
+ 'data' => $profiles
+ ), 200);
+ }
+ }
+
+ private function format_profile_data($data) {
+ return array(
+ 'attendeeId' => $data['user_id'],
+ 'profilePhoto' => $data['profile_photo'],
+ 'profession' => $data['profession'],
+ 'experience' => $data['experience'],
+ 'companyName' => $data['company_name'],
+ 'country' => $data['country'],
+ 'city' => $data['city'],
+ 'about' => $data['about'],
+ 'skills' => $data['skills'],
+ 'interests' => $data['interests'],
+ 'organizationName' => $data['organization_name'],
+ 'organizationLogo' => $data['organization_logo'],
+ 'organizationCity' => $data['organization_city'],
+ 'organizationCountry' => $data['organization_country'],
+ 'organizationDescription'=> $data['organization_description'],
+ 'messageNotification' => $data['message_notification'],
+ 'approveProfileStatus' => $data['approve_profile_status'],
+ );
+ }
+}
+
+new WPEM_REST_Attendee_Profile_Controller();
+?>
\ No newline at end of file
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 3fcc98f..4d4e93d 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -66,6 +66,10 @@ public function __construct() {
include 'includes/rest-api/wpem-rest-app-branding.php';
include 'includes/rest-api/wpem-rest-ecosystem-controller.php';
+ // match making api
+ include 'includes/rest-api/wpem-rest-matchmaking-profile.php';
+ include 'includes/rest-api/wpem-rest-edit-matchmaking-profile.php';
+
// Activate
register_activation_hook( __FILE__, array( $this, 'install' ) );
From 1c8d69285d166a5c14b10208ef243b5a66d43337 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 22 May 2025 16:50:41 +0530
Subject: [PATCH 014/171] #136 Need APIs for profile edit/update for attendee
for match making Feature
---
.../wpem-rest-edit-matchmaking-profile.php | 128 ++++++++++++------
.../wpem-rest-matchmaking-profile.php | 5 +
2 files changed, 90 insertions(+), 43 deletions(-)
diff --git a/includes/rest-api/wpem-rest-edit-matchmaking-profile.php b/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
index d10f882..4745696 100644
--- a/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
+++ b/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
@@ -33,67 +33,109 @@ public function register_routes() {
}
public function update_attendee_profile($request) {
- global $wpdb;
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $user_id = $request->get_param('user_id');
+ global $wpdb;
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $user_id = $request->get_param('user_id');
- // Check if the user exists in the table
- $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
- if (!$existing) {
+ // Check if user exists
+ $user = get_user_by('id', $user_id);
+ if (!$user) {
+ return new WP_REST_Response(array(
+ 'success' => false,
+ 'message' => 'User not found.',
+ ), 404);
+ }
+
+ // Check if profile exists in custom table
+ $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
+ if (!$existing) {
+ return new WP_REST_Response(array(
+ 'success' => false,
+ 'message' => 'Attendee profile not found in matchmaking table.',
+ ), 404);
+ }
+
+ // Custom table fields to update
+ $custom_fields = array(
+ 'profile_photo',
+ 'profession',
+ 'experience',
+ 'company_name',
+ 'country',
+ 'city',
+ 'about',
+ 'skills',
+ 'interests',
+ 'organization_name',
+ 'organization_logo',
+ 'organization_city',
+ 'organization_country',
+ 'organization_description',
+ 'message_notification',
+ 'approve_profile_status',
+ );
+
+ $custom_data = [];
+ foreach ($custom_fields as $field) {
+ if ($request->get_param($field) !== null) {
+ $custom_data[$field] = sanitize_text_field($request->get_param($field));
+ }
+ }
+
+ // Update custom table data
+ if (!empty($custom_data)) {
+ $updated = $wpdb->update($table, $custom_data, array('user_id' => $user_id));
+ if ($updated === false) {
return new WP_REST_Response(array(
'success' => false,
- 'message' => 'Attendee not found.',
- ), 404);
+ 'message' => 'Failed to update matchmaking profile.',
+ ), 500);
}
+ }
- // Get all possible fields from request
- $fields = array(
- 'profile_photo',
- 'profession',
- 'experience',
- 'company_name',
- 'country',
- 'city',
- 'about',
- 'skills',
- 'interests',
- 'organization_name',
- 'organization_logo',
- 'organization_city',
- 'organization_country',
- 'organization_description',
- 'message_notification',
- 'approve_profile_status',
- );
+ // Update WordPress user meta and email
+ $first_name = $request->get_param('first_name');
+ $last_name = $request->get_param('last_name');
+ $email = $request->get_param('email');
- $data = [];
- foreach ($fields as $field) {
- if ($request->get_param($field) !== null) {
- $data[$field] = sanitize_text_field($request->get_param($field));
- }
- }
+ if ($first_name !== null) {
+ update_user_meta($user_id, 'first_name', sanitize_text_field($first_name));
+ }
+
+ if ($last_name !== null) {
+ update_user_meta($user_id, 'last_name', sanitize_text_field($last_name));
+ }
+
+ if ($email !== null) {
+ $email = sanitize_email($email);
+ $email_exists = email_exists($email);
- if (empty($data)) {
+ if ($email_exists && $email_exists != $user_id) {
return new WP_REST_Response(array(
'success' => false,
- 'message' => 'No data provided to update.',
+ 'message' => 'Email address already in use by another user.',
), 400);
}
- $updated = $wpdb->update($table, $data, array('user_id' => $user_id));
+ $email_update = wp_update_user(array(
+ 'ID' => $user_id,
+ 'user_email' => $email,
+ ));
- if ($updated === false) {
+ if (is_wp_error($email_update)) {
return new WP_REST_Response(array(
'success' => false,
- 'message' => 'Failed to update attendee profile.',
+ 'message' => 'Failed to update email.',
+ 'error' => $email_update->get_error_message(),
), 500);
}
-
- return new WP_REST_Response(array(
- 'success' => true,
- 'message' => 'Attendee profile updated successfully.',
- ), 200);
}
+
+ return new WP_REST_Response(array(
+ 'success' => true,
+ 'message' => 'Attendee profile updated successfully.',
+ ), 200);
+}
}
new WPEM_REST_Attendee_Profile_Update_Controller();
diff --git a/includes/rest-api/wpem-rest-matchmaking-profile.php b/includes/rest-api/wpem-rest-matchmaking-profile.php
index 98a6af4..87adfe4 100644
--- a/includes/rest-api/wpem-rest-matchmaking-profile.php
+++ b/includes/rest-api/wpem-rest-matchmaking-profile.php
@@ -64,8 +64,13 @@ public function get_attendee_profile($request) {
}
private function format_profile_data($data) {
+ $user = get_userdata($data['user_id']);
+
return array(
'attendeeId' => $data['user_id'],
+ 'firstName' => $user ? get_user_meta($user->ID, 'first_name', true) : '',
+ 'lastName' => $user ? get_user_meta($user->ID, 'last_name', true) : '',
+ 'email' => $user ? $user->user_email : '',
'profilePhoto' => $data['profile_photo'],
'profession' => $data['profession'],
'experience' => $data['experience'],
From 0d6e2200f3ea4c3dbcb5489fc2f22d6e1a0d1e9a Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Thu, 22 May 2025 17:50:18 +0530
Subject: [PATCH 015/171] Login API Changes #158
---
includes/rest-api/wpem-rest-authentication.php | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 3af61eb..6b593d7 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -690,7 +690,7 @@ public function perform_user_authentication($request){
$data = array(
'token' => $token,
'user' => array(
- 'user_id' => $user->ID,
+ 'user_id' => $user_id,
'user_email' => $user->user_email,
'first_name' => $user->first_name,
'last_name' => $user->last_name,
@@ -715,7 +715,9 @@ public function perform_user_authentication($request){
$key_data->expiry = true;
}
$data['organizer_info'] = $key_data;
- }
+ }
+ if( empty( $key_data ) && !get_user_meta($user_id, '_matchmaking_profile', true))
+ return parent::prepare_error_for_response(405);
$response_data = parent::prepare_error_for_response(200);
$response_data['data'] = $data;
return $response_data;
@@ -751,4 +753,4 @@ public function wpem_generate_jwt_token($user_id) {
}
}
-new WPEM_REST_Authentication();
\ No newline at end of file
+new WPEM_REST_Authentication();
From 442bf3d272ac3427b0037f7fa106100bf8a7ef37 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 23 May 2025 15:09:20 +0530
Subject: [PATCH 016/171] #159 Ecosystem API Changes
---
wpem-rest-api-functions.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/wpem-rest-api-functions.php b/wpem-rest-api-functions.php
index f240a41..abd4b71 100644
--- a/wpem-rest-api-functions.php
+++ b/wpem-rest-api-functions.php
@@ -277,6 +277,7 @@ function get_wpem_rest_api_ecosystem_info(){
'wp-event-manager-sell-tickets' => 'WP Event Manager Sell Tickets',
'wp-event-manager-registrations' => 'WP Event Manager Registrations',
'wpem-guests' => 'WP Event Manager Guests',
+ 'wpem-speaker-schedule' => 'WP Event Manager Speaker & Schedule'
) );
// Get ecosystem data
From 96a2e8b550f3bec062842da53f2598fb990a3dcd Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 23 May 2025 17:14:56 +0530
Subject: [PATCH 017/171] #158 Login API Changes
---
includes/rest-api/wpem-rest-authentication.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 6b593d7..154240f 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -686,6 +686,7 @@ public function perform_user_authentication($request){
$user_id = $user->ID;
$token = $this->wpem_generate_jwt_token($user->ID);
+ $is_matchmaking = get_user_meta($user_id, '_matchmaking_profile', true);
$data = array(
'token' => $token,
@@ -695,6 +696,7 @@ public function perform_user_authentication($request){
'first_name' => $user->first_name,
'last_name' => $user->last_name,
'username' => $user->user_login,
+ 'matchmaking_profile' => $is_matchmaking,
)
);
From c525ab82a54ebe98c321299c2a1deaac0259bec5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 23 May 2025 18:47:18 +0530
Subject: [PATCH 018/171] #136 change response structure as per other response
---
.../wpem-rest-edit-matchmaking-profile.php | 210 +++++++++---------
.../wpem-rest-matchmaking-profile.php | 58 ++---
2 files changed, 139 insertions(+), 129 deletions(-)
diff --git a/includes/rest-api/wpem-rest-edit-matchmaking-profile.php b/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
index 4745696..b336495 100644
--- a/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
+++ b/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
@@ -33,109 +33,115 @@ public function register_routes() {
}
public function update_attendee_profile($request) {
- global $wpdb;
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $user_id = $request->get_param('user_id');
-
- // Check if user exists
- $user = get_user_by('id', $user_id);
- if (!$user) {
- return new WP_REST_Response(array(
- 'success' => false,
- 'message' => 'User not found.',
- ), 404);
- }
-
- // Check if profile exists in custom table
- $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
- if (!$existing) {
- return new WP_REST_Response(array(
- 'success' => false,
- 'message' => 'Attendee profile not found in matchmaking table.',
- ), 404);
- }
-
- // Custom table fields to update
- $custom_fields = array(
- 'profile_photo',
- 'profession',
- 'experience',
- 'company_name',
- 'country',
- 'city',
- 'about',
- 'skills',
- 'interests',
- 'organization_name',
- 'organization_logo',
- 'organization_city',
- 'organization_country',
- 'organization_description',
- 'message_notification',
- 'approve_profile_status',
- );
-
- $custom_data = [];
- foreach ($custom_fields as $field) {
- if ($request->get_param($field) !== null) {
- $custom_data[$field] = sanitize_text_field($request->get_param($field));
- }
- }
-
- // Update custom table data
- if (!empty($custom_data)) {
- $updated = $wpdb->update($table, $custom_data, array('user_id' => $user_id));
- if ($updated === false) {
- return new WP_REST_Response(array(
- 'success' => false,
- 'message' => 'Failed to update matchmaking profile.',
- ), 500);
- }
- }
-
- // Update WordPress user meta and email
- $first_name = $request->get_param('first_name');
- $last_name = $request->get_param('last_name');
- $email = $request->get_param('email');
+ global $wpdb;
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $user_id = $request->get_param('user_id');
+
+ $user = get_user_by('id', $user_id);
+ if (!$user) {
+ return new WP_REST_Response(array(
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'User not found.',
+ 'data' => null
+ ), 404);
+ }
+
+ $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
+ if (!$existing) {
+ return new WP_REST_Response(array(
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'Attendee profile not found in matchmaking table.',
+ 'data' => null
+ ), 404);
+ }
+
+ $custom_fields = array(
+ 'profile_photo',
+ 'profession',
+ 'experience',
+ 'company_name',
+ 'country',
+ 'city',
+ 'about',
+ 'skills',
+ 'interests',
+ 'organization_name',
+ 'organization_logo',
+ 'organization_city',
+ 'organization_country',
+ 'organization_description',
+ 'message_notification',
+ 'approve_profile_status',
+ );
+
+ $custom_data = [];
+ foreach ($custom_fields as $field) {
+ if ($request->get_param($field) !== null) {
+ $custom_data[$field] = sanitize_text_field($request->get_param($field));
+ }
+ }
+
+ if (!empty($custom_data)) {
+ $updated = $wpdb->update($table, $custom_data, array('user_id' => $user_id));
+ if ($updated === false) {
+ return new WP_REST_Response(array(
+ 'code' => 500,
+ 'status' => 'Error',
+ 'message' => 'Failed to update matchmaking profile.',
+ 'data' => null
+ ), 500);
+ }
+ }
+
+ $first_name = $request->get_param('first_name');
+ $last_name = $request->get_param('last_name');
+ $email = $request->get_param('email');
+
+ if ($first_name !== null) {
+ update_user_meta($user_id, 'first_name', sanitize_text_field($first_name));
+ }
+
+ if ($last_name !== null) {
+ update_user_meta($user_id, 'last_name', sanitize_text_field($last_name));
+ }
+
+ if ($email !== null) {
+ $email = sanitize_email($email);
+ $email_exists = email_exists($email);
+
+ if ($email_exists && $email_exists != $user_id) {
+ return new WP_REST_Response(array(
+ 'code' => 400,
+ 'status' => 'Error',
+ 'message' => 'Email address already in use by another user.',
+ 'data' => null
+ ), 400);
+ }
+
+ $email_update = wp_update_user(array(
+ 'ID' => $user_id,
+ 'user_email' => $email,
+ ));
+
+ if (is_wp_error($email_update)) {
+ return new WP_REST_Response(array(
+ 'code' => 500,
+ 'status' => 'Error',
+ 'message' => 'Failed to update email.',
+ 'data' => $email_update->get_error_message()
+ ), 500);
+ }
+ }
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Request is successfully completed.',
+ ), 200);
+ }
- if ($first_name !== null) {
- update_user_meta($user_id, 'first_name', sanitize_text_field($first_name));
- }
-
- if ($last_name !== null) {
- update_user_meta($user_id, 'last_name', sanitize_text_field($last_name));
- }
-
- if ($email !== null) {
- $email = sanitize_email($email);
- $email_exists = email_exists($email);
-
- if ($email_exists && $email_exists != $user_id) {
- return new WP_REST_Response(array(
- 'success' => false,
- 'message' => 'Email address already in use by another user.',
- ), 400);
- }
-
- $email_update = wp_update_user(array(
- 'ID' => $user_id,
- 'user_email' => $email,
- ));
-
- if (is_wp_error($email_update)) {
- return new WP_REST_Response(array(
- 'success' => false,
- 'message' => 'Failed to update email.',
- 'error' => $email_update->get_error_message(),
- ), 500);
- }
- }
-
- return new WP_REST_Response(array(
- 'success' => true,
- 'message' => 'Attendee profile updated successfully.',
- ), 200);
-}
}
new WPEM_REST_Attendee_Profile_Update_Controller();
diff --git a/includes/rest-api/wpem-rest-matchmaking-profile.php b/includes/rest-api/wpem-rest-matchmaking-profile.php
index 87adfe4..c293a7c 100644
--- a/includes/rest-api/wpem-rest-matchmaking-profile.php
+++ b/includes/rest-api/wpem-rest-matchmaking-profile.php
@@ -37,17 +37,20 @@ public function get_attendee_profile($request) {
if (!$data) {
return new WP_REST_Response(array(
- 'success' => false,
- 'message' => 'Attendee not found.'
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'Attendee not found.',
+ 'data' => null
), 404);
}
$profile = $this->format_profile_data($data);
return new WP_REST_Response(array(
- 'success' => true,
- 'message' => 'Profile retrieved successfully.',
- 'data' => $profile
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Request is successfully completed.',
+ 'data' => $profile
), 200);
} else {
// Fetch all attendees
@@ -56,9 +59,10 @@ public function get_attendee_profile($request) {
$profiles = array_map(array($this, 'format_profile_data'), $results);
return new WP_REST_Response(array(
- 'success' => true,
+ 'code' => 200,
+ 'status' => 'OK',
'message' => 'All attendee profiles retrieved successfully.',
- 'data' => $profiles
+ 'data' => $profiles
), 200);
}
}
@@ -67,26 +71,26 @@ private function format_profile_data($data) {
$user = get_userdata($data['user_id']);
return array(
- 'attendeeId' => $data['user_id'],
- 'firstName' => $user ? get_user_meta($user->ID, 'first_name', true) : '',
- 'lastName' => $user ? get_user_meta($user->ID, 'last_name', true) : '',
- 'email' => $user ? $user->user_email : '',
- 'profilePhoto' => $data['profile_photo'],
- 'profession' => $data['profession'],
- 'experience' => $data['experience'],
- 'companyName' => $data['company_name'],
- 'country' => $data['country'],
- 'city' => $data['city'],
- 'about' => $data['about'],
- 'skills' => $data['skills'],
- 'interests' => $data['interests'],
- 'organizationName' => $data['organization_name'],
- 'organizationLogo' => $data['organization_logo'],
- 'organizationCity' => $data['organization_city'],
- 'organizationCountry' => $data['organization_country'],
- 'organizationDescription'=> $data['organization_description'],
- 'messageNotification' => $data['message_notification'],
- 'approveProfileStatus' => $data['approve_profile_status'],
+ 'attendeeId' => $data['user_id'],
+ 'firstName' => $user ? get_user_meta($user->ID, 'first_name', true) : '',
+ 'lastName' => $user ? get_user_meta($user->ID, 'last_name', true) : '',
+ 'email' => $user ? $user->user_email : '',
+ 'profilePhoto' => $data['profile_photo'],
+ 'profession' => $data['profession'],
+ 'experience' => $data['experience'],
+ 'companyName' => $data['company_name'],
+ 'country' => $data['country'],
+ 'city' => $data['city'],
+ 'about' => $data['about'],
+ 'skills' => $data['skills'],
+ 'interests' => $data['interests'],
+ 'organizationName' => $data['organization_name'],
+ 'organizationLogo' => $data['organization_logo'],
+ 'organizationCity' => $data['organization_city'],
+ 'organizationCountry' => $data['organization_country'],
+ 'organizationDescription' => $data['organization_description'],
+ 'messageNotification' => $data['message_notification'],
+ 'approveProfileStatus' => $data['approve_profile_status'],
);
}
}
From 66b3a7dc8ad60002a2c362e81cf2c0d4ab28e855 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 11:23:14 +0530
Subject: [PATCH 019/171] #161 Master Api for DropDown Details
Add code in response if match making is not enable from backend setting.
---
.../wpem-rest-edit-matchmaking-profile.php | 150 ------------------
.../wpem-rest-matchmaking-get-texonomy.php | 85 ++++++++++
.../wpem-rest-matchmaking-profile.php | 125 +++++++++++++--
wpem-rest-api.php | 2 +-
4 files changed, 200 insertions(+), 162 deletions(-)
delete mode 100644 includes/rest-api/wpem-rest-edit-matchmaking-profile.php
create mode 100644 includes/rest-api/wpem-rest-matchmaking-get-texonomy.php
diff --git a/includes/rest-api/wpem-rest-edit-matchmaking-profile.php b/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
deleted file mode 100644
index b336495..0000000
--- a/includes/rest-api/wpem-rest-edit-matchmaking-profile.php
+++ /dev/null
@@ -1,150 +0,0 @@
-namespace,
- '/' . $this->rest_base . '/update',
- array(
- 'methods' => WP_REST_Server::EDITABLE, // PUT/PATCH/POST
- 'callback' => array($this, 'update_attendee_profile'),
- 'permission_callback' => '__return_true', // For testing, allow all (you should restrict this in production)
- 'args' => array(
- 'user_id' => array(
- 'required' => true,
- 'type' => 'integer',
- ),
- ),
- )
- );
- }
-
- public function update_attendee_profile($request) {
- global $wpdb;
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $user_id = $request->get_param('user_id');
-
- $user = get_user_by('id', $user_id);
- if (!$user) {
- return new WP_REST_Response(array(
- 'code' => 404,
- 'status' => 'Not Found',
- 'message' => 'User not found.',
- 'data' => null
- ), 404);
- }
-
- $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
- if (!$existing) {
- return new WP_REST_Response(array(
- 'code' => 404,
- 'status' => 'Not Found',
- 'message' => 'Attendee profile not found in matchmaking table.',
- 'data' => null
- ), 404);
- }
-
- $custom_fields = array(
- 'profile_photo',
- 'profession',
- 'experience',
- 'company_name',
- 'country',
- 'city',
- 'about',
- 'skills',
- 'interests',
- 'organization_name',
- 'organization_logo',
- 'organization_city',
- 'organization_country',
- 'organization_description',
- 'message_notification',
- 'approve_profile_status',
- );
-
- $custom_data = [];
- foreach ($custom_fields as $field) {
- if ($request->get_param($field) !== null) {
- $custom_data[$field] = sanitize_text_field($request->get_param($field));
- }
- }
-
- if (!empty($custom_data)) {
- $updated = $wpdb->update($table, $custom_data, array('user_id' => $user_id));
- if ($updated === false) {
- return new WP_REST_Response(array(
- 'code' => 500,
- 'status' => 'Error',
- 'message' => 'Failed to update matchmaking profile.',
- 'data' => null
- ), 500);
- }
- }
-
- $first_name = $request->get_param('first_name');
- $last_name = $request->get_param('last_name');
- $email = $request->get_param('email');
-
- if ($first_name !== null) {
- update_user_meta($user_id, 'first_name', sanitize_text_field($first_name));
- }
-
- if ($last_name !== null) {
- update_user_meta($user_id, 'last_name', sanitize_text_field($last_name));
- }
-
- if ($email !== null) {
- $email = sanitize_email($email);
- $email_exists = email_exists($email);
-
- if ($email_exists && $email_exists != $user_id) {
- return new WP_REST_Response(array(
- 'code' => 400,
- 'status' => 'Error',
- 'message' => 'Email address already in use by another user.',
- 'data' => null
- ), 400);
- }
-
- $email_update = wp_update_user(array(
- 'ID' => $user_id,
- 'user_email' => $email,
- ));
-
- if (is_wp_error($email_update)) {
- return new WP_REST_Response(array(
- 'code' => 500,
- 'status' => 'Error',
- 'message' => 'Failed to update email.',
- 'data' => $email_update->get_error_message()
- ), 500);
- }
- }
-
- return new WP_REST_Response(array(
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Request is successfully completed.',
- ), 200);
- }
-
-}
-
-new WPEM_REST_Attendee_Profile_Update_Controller();
-
-
-?>
\ No newline at end of file
diff --git a/includes/rest-api/wpem-rest-matchmaking-get-texonomy.php b/includes/rest-api/wpem-rest-matchmaking-get-texonomy.php
new file mode 100644
index 0000000..cfd220d
--- /dev/null
+++ b/includes/rest-api/wpem-rest-matchmaking-get-texonomy.php
@@ -0,0 +1,85 @@
+namespace,
+ '/' . $this->rest_base,
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'get_taxonomy_terms'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'taxonomy' => array(
+ 'required' => true,
+ 'type' => 'string',
+ 'description' => 'Taxonomy name (e.g., category, post_tag, custom_taxonomy).',
+ )
+ ),
+ )
+ );
+ }
+
+ public function get_taxonomy_terms($request) {
+ // Check if matchmaking is enabled
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response(array(
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ), 403);
+ }
+
+ $taxonomy = sanitize_text_field($request->get_param('taxonomy'));
+
+ if (!taxonomy_exists($taxonomy)) {
+ return new WP_REST_Response(array(
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'Invalid taxonomy.',
+ 'data' => null
+ ), 400);
+ }
+
+ $terms = get_terms(array(
+ 'taxonomy' => $taxonomy,
+ 'hide_empty' => false,
+ ));
+
+ if (is_wp_error($terms)) {
+ return new WP_REST_Response(array(
+ 'code' => 500,
+ 'status' => 'Server Error',
+ 'message' => 'Failed to fetch terms.',
+ 'data' => null
+ ), 500);
+ }
+
+ $term_list = array_map(array($this, 'format_term_data'), $terms);
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Taxonomy terms retrieved successfully.',
+ 'data' => $term_list
+ ), 200);
+ }
+
+ private function format_term_data($term) {
+ return array(
+ 'id' => $term->term_id,
+ 'name' => $term->name,
+ 'slug' => $term->slug,
+ );
+ }
+}
+
+new WPEM_REST_Taxonomy_List_Controller();
diff --git a/includes/rest-api/wpem-rest-matchmaking-profile.php b/includes/rest-api/wpem-rest-matchmaking-profile.php
index c293a7c..de51d6a 100644
--- a/includes/rest-api/wpem-rest-matchmaking-profile.php
+++ b/includes/rest-api/wpem-rest-matchmaking-profile.php
@@ -1,6 +1,10 @@
403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ), 403);
+ }
+
global $wpdb;
$attendee_id = $request->get_param('attendeeId');
$table = $wpdb->prefix . 'wpem_matchmaking_users';
if ($attendee_id) {
- // Fetch single attendee
$data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $attendee_id), ARRAY_A);
-
if (!$data) {
return new WP_REST_Response(array(
'code' => 404,
@@ -43,25 +54,20 @@ public function get_attendee_profile($request) {
'data' => null
), 404);
}
-
$profile = $this->format_profile_data($data);
-
return new WP_REST_Response(array(
'code' => 200,
'status' => 'OK',
- 'message' => 'Request is successfully completed.',
+ 'message' => 'Profile retrieved successfully.',
'data' => $profile
), 200);
} else {
- // Fetch all attendees
$results = $wpdb->get_results("SELECT * FROM $table", ARRAY_A);
-
$profiles = array_map(array($this, 'format_profile_data'), $results);
-
return new WP_REST_Response(array(
'code' => 200,
'status' => 'OK',
- 'message' => 'All attendee profiles retrieved successfully.',
+ 'message' => 'All profiles retrieved successfully.',
'data' => $profiles
), 200);
}
@@ -95,5 +101,102 @@ private function format_profile_data($data) {
}
}
+
+/**
+ * REST API Attendee Profile UPDATE controller class.
+ */
+class WPEM_REST_Attendee_Profile_Update_Controller {
+ protected $namespace = 'wpem';
+ protected $rest_base = 'attendee-profile';
+
+ public function __construct() {
+ add_action('rest_api_init', array($this, 'register_routes'), 10);
+ }
+
+ public function register_routes() {
+ register_rest_route(
+ $this->namespace,
+ '/' . $this->rest_base . '/update',
+ array(
+ 'methods' => WP_REST_Server::EDITABLE,
+ 'callback' => array($this, 'update_attendee_profile'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'user_id' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ ),
+ ),
+ )
+ );
+ }
+
+ public function update_attendee_profile($request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.'
+ ], 403);
+ }
+
+ global $wpdb;
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $user_id = $request->get_param('user_id');
+
+ $user = get_user_by('id', $user_id);
+ if (!$user) {
+ return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'User not found.'], 404);
+ }
+
+ $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
+ if (!$existing) {
+ return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'Profile not found.'], 404);
+ }
+
+ $custom_fields = [
+ 'profile_photo', 'profession', 'experience', 'company_name', 'country',
+ 'city', 'about', 'skills', 'interests', 'organization_name', 'organization_logo',
+ 'organization_city', 'organization_country', 'organization_description',
+ 'message_notification', 'approve_profile_status',
+ ];
+
+ $custom_data = [];
+ foreach ($custom_fields as $field) {
+ if ($request->get_param($field) !== null) {
+ $custom_data[$field] = sanitize_text_field($request->get_param($field));
+ }
+ }
+
+ if (!empty($custom_data)) {
+ $updated = $wpdb->update($table, $custom_data, ['user_id' => $user_id]);
+ if ($updated === false) {
+ return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Failed to update profile.'], 500);
+ }
+ }
+
+ if ($first = $request->get_param('first_name')) {
+ update_user_meta($user_id, 'first_name', sanitize_text_field($first));
+ }
+ if ($last = $request->get_param('last_name')) {
+ update_user_meta($user_id, 'last_name', sanitize_text_field($last));
+ }
+ if ($email = $request->get_param('email')) {
+ $email = sanitize_email($email);
+ $email_exists = email_exists($email);
+ if ($email_exists && $email_exists != $user_id) {
+ return new WP_REST_Response(['code' => 400, 'status' => 'Error', 'message' => 'Email already in use.'], 400);
+ }
+ $result = wp_update_user(['ID' => $user_id, 'user_email' => $email]);
+ if (is_wp_error($result)) {
+ return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => $result->get_error_message()], 500);
+ }
+ }
+
+ return new WP_REST_Response(['code' => 200, 'status' => 'OK', 'message' => 'Profile updated successfully.'], 200);
+ }
+}
+
+// Initialize both controllers
new WPEM_REST_Attendee_Profile_Controller();
-?>
\ No newline at end of file
+new WPEM_REST_Attendee_Profile_Update_Controller();
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 4d4e93d..7a9fb98 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -68,7 +68,7 @@ public function __construct() {
// match making api
include 'includes/rest-api/wpem-rest-matchmaking-profile.php';
- include 'includes/rest-api/wpem-rest-edit-matchmaking-profile.php';
+ include 'includes/rest-api/wpem-rest-matchmaking-get-texonomy.php';
// Activate
register_activation_hook( __FILE__, array( $this, 'install' ) );
From 858069a6696105bee72c1a85d763eaefcdc1f532 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 11:43:13 +0530
Subject: [PATCH 020/171] #158 Add flag for enable match making or not
---
includes/rest-api/wpem-rest-authentication.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/rest-api/wpem-rest-authentication.php
index 154240f..e3ba472 100644
--- a/includes/rest-api/wpem-rest-authentication.php
+++ b/includes/rest-api/wpem-rest-authentication.php
@@ -687,6 +687,7 @@ public function perform_user_authentication($request){
$token = $this->wpem_generate_jwt_token($user->ID);
$is_matchmaking = get_user_meta($user_id, '_matchmaking_profile', true);
+ $enable_matchmaking = get_option('enable_matchmaking', false) ? 1 : 0;
$data = array(
'token' => $token,
@@ -697,6 +698,7 @@ public function perform_user_authentication($request){
'last_name' => $user->last_name,
'username' => $user->user_login,
'matchmaking_profile' => $is_matchmaking,
+ 'enable_matchmaking' => $enable_matchmaking,
)
);
From dd574093001cf99839326874ef6b05961873438b Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 11:57:38 +0530
Subject: [PATCH 021/171] #4 Need to set validation for select back dates.
---
assets/js/admin.js | 2 +-
assets/js/admin.min.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/assets/js/admin.js b/assets/js/admin.js
index b33d68d..6280684 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -4,7 +4,7 @@ var WPEMRestAPIAdmin = (function () {
jQuery("#update_api_key").on("click", WPEMRestAPIAdmin.actions.saveApiKey),
jQuery("select#key_user").chosen(),
jQuery("select#event_id").chosen(),
- jQuery("input#date_expires").datepicker({ dateFormat: "yy-mm-dd" }),
+ jQuery("input#date_expires").datepicker({dateFormat: "yy-mm-dd",minDate: 0}),
jQuery("table#app-branding-color-dark").hide(),
jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click(function () {
jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"), jQuery("table#app-branding-color").show(), jQuery("table#app-branding-color-dark").hide();
diff --git a/assets/js/admin.min.js b/assets/js/admin.min.js
index 4a8907c..df02410 100644
--- a/assets/js/admin.min.js
+++ b/assets/js/admin.min.js
@@ -1 +1 @@
-var WPEMRestAPIAdmin={init:function(){var e;jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd"}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}})},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
")},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
+var WPEMRestAPIAdmin={init:function(){var e;jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}})},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
")},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
From 5ca6d7dee124b2ed71b45e04efed77b750074470 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 13:15:55 +0530
Subject: [PATCH 022/171] #146 create message api
---
.../wpem-rest-matchmaking-user-messages.php | 143 ++++++++++++++++++
wpem-rest-api.php | 1 +
2 files changed, 144 insertions(+)
create mode 100644 includes/rest-api/wpem-rest-matchmaking-user-messages.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-user-messages.php b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
new file mode 100644
index 0000000..e281aed
--- /dev/null
+++ b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
@@ -0,0 +1,143 @@
+namespace,
+ '/' . $this->rest_base,
+ array(
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array($this, 'handle_send_message'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'senderId' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ ),
+ 'receiverId' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ ),
+ 'message' => array(
+ 'required' => true,
+ 'type' => 'string',
+ ),
+ 'eventId' => array(
+ 'required' => false,
+ 'type' => 'integer',
+ ),
+ ),
+ )
+ );
+ }
+
+ public function handle_send_message($request) {
+
+ // Check if matchmaking is enabled
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response(array(
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ), 403);
+ }
+
+ global $wpdb;
+
+ $sender_id = intval($request->get_param('senderId'));
+ $receiver_id = intval($request->get_param('receiverId'));
+ $message = sanitize_textarea_field($request->get_param('message'));
+ $event_id = intval($request->get_param('eventId'));
+
+ // Validate users
+ $sender_user = get_user_by('id', $sender_id);
+ $receiver_user = get_user_by('id', $receiver_id);
+
+ if (!$sender_user) {
+ return new WP_REST_Response(['success' => 0, 'message' => 'Sender not found.'], 404);
+ }
+
+ if (!$receiver_user) {
+ return new WP_REST_Response(['success' => 0, 'message' => 'Receiver not found.'], 404);
+ }
+
+ $first_name = get_user_meta($sender_id, 'first_name', true);
+ $last_name = get_user_meta($sender_id, 'last_name', true);
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
+ $today = date('Y-m-d');
+
+ // Check if the user already sent a message to the same participant today
+ $existing_count = $wpdb->get_var($wpdb->prepare(
+ "SELECT COUNT(*) FROM $table
+ WHERE sender_id = %d AND receiver_id = %d
+ AND DATE(created_at) = %s",
+ $sender_id, $receiver_id, $today
+ ));
+
+ $parent_id = ($existing_count == 0) ? 1 : 0;
+
+ // Insert message
+ $inserted = $wpdb->insert(
+ $table,
+ array(
+ 'event_id' => $event_id,
+ 'parent_id' => $parent_id,
+ 'sender_id' => $sender_id,
+ 'receiver_id' => $receiver_id,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
+ 'message' => $message,
+ 'created_at' => current_time('mysql'),
+ ),
+ array('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s')
+ );
+
+ if (!$inserted) {
+ return new WP_REST_Response([
+ 'success' => 0,
+ 'message' => 'Failed to save message.',
+ 'error' => $wpdb->last_error
+ ], 500);
+ }
+
+ // Send email
+ $to = $receiver_user->user_email;
+ $subject = 'New Message from ' . $sender_user->display_name;
+ $body = "You have received a new message:\n\n" . $message . "\n\nFrom: " . $sender_user->display_name;
+ $headers = array('Content-Type: text/plain; charset=UTF-8');
+ wp_mail($to, $subject, $body, $headers);
+
+ return new WP_REST_Response(array(
+ 'success' => 1,
+ 'message' => 'Message sent and saved successfully.',
+ 'data' => array(
+ 'id' => $wpdb->insert_id,
+ 'event_id' => $event_id,
+ 'parent_id' => $parent_id,
+ 'sender_id' => $sender_id,
+ 'receiver_id' => $receiver_id,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
+ 'message' => $message,
+ 'created_at' => current_time('mysql'),
+ )
+ ), 200);
+ }
+}
+
+new WPEM_REST_Send_Message_Controller();
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 7a9fb98..7719841 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -69,6 +69,7 @@ public function __construct() {
// match making api
include 'includes/rest-api/wpem-rest-matchmaking-profile.php';
include 'includes/rest-api/wpem-rest-matchmaking-get-texonomy.php';
+ include 'includes/rest-api/wpem-rest-matchmaking-user-messages.php';
// Activate
register_activation_hook( __FILE__, array( $this, 'install' ) );
From 51e8619f97865f4985c55c1c9dafa21010b994d5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 14:36:50 +0530
Subject: [PATCH 023/171] #146 Get message conversation api
---
.../wpem-rest-matchmaking-user-messages.php | 190 ++++++++++--------
1 file changed, 108 insertions(+), 82 deletions(-)
diff --git a/includes/rest-api/wpem-rest-matchmaking-user-messages.php b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
index e281aed..69f8ac2 100644
--- a/includes/rest-api/wpem-rest-matchmaking-user-messages.php
+++ b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
@@ -1,10 +1,6 @@
namespace,
- '/' . $this->rest_base,
- array(
- 'methods' => WP_REST_Server::CREATABLE,
- 'callback' => array($this, 'handle_send_message'),
- 'permission_callback' => '__return_true',
- 'args' => array(
- 'senderId' => array(
- 'required' => true,
- 'type' => 'integer',
- ),
- 'receiverId' => array(
- 'required' => true,
- 'type' => 'integer',
- ),
- 'message' => array(
- 'required' => true,
- 'type' => 'string',
- ),
- 'eventId' => array(
- 'required' => false,
- 'type' => 'integer',
- ),
- ),
- )
- );
+ register_rest_route($this->namespace, '/' . $this->rest_base, array(
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array($this, 'handle_send_message'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'senderId' => array('required' => true, 'type' => 'integer'),
+ 'receiverId' => array('required' => true, 'type' => 'integer'),
+ 'message' => array('required' => true, 'type' => 'string'),
+ 'eventId' => array('required' => false, 'type' => 'integer'),
+ ),
+ ));
+
+ register_rest_route($this->namespace, '/get-messages', array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'handle_get_messages'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'senderId' => array('required' => true, 'type' => 'integer'),
+ 'receiverId' => array('required' => true, 'type' => 'integer'),
+ ),
+ ));
}
public function handle_send_message($request) {
-
- // Check if matchmaking is enabled
+ global $wpdb;
+
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response(array(
'code' => 403,
@@ -55,88 +45,124 @@ public function handle_send_message($request) {
'data' => null
), 403);
}
-
- global $wpdb;
$sender_id = intval($request->get_param('senderId'));
$receiver_id = intval($request->get_param('receiverId'));
$message = sanitize_textarea_field($request->get_param('message'));
$event_id = intval($request->get_param('eventId'));
- // Validate users
$sender_user = get_user_by('id', $sender_id);
$receiver_user = get_user_by('id', $receiver_id);
-
- if (!$sender_user) {
- return new WP_REST_Response(['success' => 0, 'message' => 'Sender not found.'], 404);
- }
-
- if (!$receiver_user) {
- return new WP_REST_Response(['success' => 0, 'message' => 'Receiver not found.'], 404);
+ if (!$sender_user || !$receiver_user) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'Sender or Receiver not found.',
+ 'data' => null
+ ], 404);
}
$first_name = get_user_meta($sender_id, 'first_name', true);
$last_name = get_user_meta($sender_id, 'last_name', true);
+ // Determine parent_id (new conversation for the day = parent_id 1)
$table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
$today = date('Y-m-d');
- // Check if the user already sent a message to the same participant today
- $existing_count = $wpdb->get_var($wpdb->prepare(
+ $existing = $wpdb->get_var($wpdb->prepare(
"SELECT COUNT(*) FROM $table
WHERE sender_id = %d AND receiver_id = %d
AND DATE(created_at) = %s",
$sender_id, $receiver_id, $today
));
- $parent_id = ($existing_count == 0) ? 1 : 0;
-
- // Insert message
- $inserted = $wpdb->insert(
- $table,
- array(
- 'event_id' => $event_id,
- 'parent_id' => $parent_id,
- 'sender_id' => $sender_id,
- 'receiver_id' => $receiver_id,
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'message' => $message,
- 'created_at' => current_time('mysql'),
- ),
- array('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s')
- );
+ $parent_id = ($existing == 0) ? 1 : 0;
+
+ $inserted = $wpdb->insert($table, array(
+ 'event_id' => $event_id,
+ 'parent_id' => $parent_id,
+ 'sender_id' => $sender_id,
+ 'receiver_id' => $receiver_id,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
+ 'message' => $message,
+ 'created_at' => current_time('mysql')
+ ), array('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s'));
if (!$inserted) {
return new WP_REST_Response([
- 'success' => 0,
+ 'code' => 500,
+ 'status' => 'Error',
'message' => 'Failed to save message.',
- 'error' => $wpdb->last_error
+ 'data' => $wpdb->last_error
], 500);
}
- // Send email
- $to = $receiver_user->user_email;
- $subject = 'New Message from ' . $sender_user->display_name;
- $body = "You have received a new message:\n\n" . $message . "\n\nFrom: " . $sender_user->display_name;
- $headers = array('Content-Type: text/plain; charset=UTF-8');
- wp_mail($to, $subject, $body, $headers);
+ wp_mail(
+ $receiver_user->user_email,
+ 'New Message from ' . $sender_user->display_name,
+ "You have received a new message:\n\n" . $message . "\n\nFrom: " . $sender_user->display_name,
+ array('Content-Type: text/plain; charset=UTF-8')
+ );
- return new WP_REST_Response(array(
- 'success' => 1,
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
'message' => 'Message sent and saved successfully.',
'data' => array(
- 'id' => $wpdb->insert_id,
- 'event_id' => $event_id,
- 'parent_id' => $parent_id,
- 'sender_id' => $sender_id,
- 'receiver_id' => $receiver_id,
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'message' => $message,
- 'created_at' => current_time('mysql'),
+ 'id' => $wpdb->insert_id,
+ 'event_id' => $event_id,
+ 'parent_id' => $parent_id,
+ 'sender_id' => $sender_id,
+ 'receiver_id'=> $receiver_id,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
+ 'message' => $message,
+ 'created_at' => current_time('mysql'),
)
- ), 200);
+ ], 200);
+ }
+
+ public function handle_get_messages($request) {
+ global $wpdb;
+
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response(array(
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ), 403);
+ }
+
+ $sender_id = intval($request->get_param('senderId'));
+ $receiver_id = intval($request->get_param('receiverId'));
+
+ if (!$sender_id || !$receiver_id) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'senderId and receiverId are required.',
+ 'data' => null
+ ], 400);
+ }
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
+
+ $messages = $wpdb->get_results($wpdb->prepare(
+ "SELECT * FROM $table
+ WHERE (sender_id = %d AND receiver_id = %d)
+ OR (sender_id = %d AND receiver_id = %d)
+ ORDER BY created_at ASC",
+ $sender_id, $receiver_id, $receiver_id, $sender_id
+ ), ARRAY_A);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Messages retrieved successfully.',
+ 'data' => $messages
+ ], 200);
}
}
From c2cd10783c6b8c98bf96239a0c95d2c1eee8ddbc Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 14:49:02 +0530
Subject: [PATCH 024/171] #146 Put validation as per the enable notification
settings from user profile
---
.../wpem-rest-matchmaking-user-messages.php | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/includes/rest-api/wpem-rest-matchmaking-user-messages.php b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
index 69f8ac2..87fc107 100644
--- a/includes/rest-api/wpem-rest-matchmaking-user-messages.php
+++ b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
@@ -61,6 +61,24 @@ public function handle_send_message($request) {
'data' => null
], 404);
}
+ // Check message_notification in wp_wpem_matchmaking_users table
+ $table_users = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ $sender_notify = $wpdb->get_var(
+ $wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $sender_id)
+ );
+
+ $receiver_notify = $wpdb->get_var(
+ $wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $receiver_id)
+ );
+
+ if ($sender_notify !== 1 || $receiver_notify !== 1) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Forbidden',
+ 'message' => 'Both sender and receiver must have message notifications enabled to send messages.',
+ ], 403);
+ }
$first_name = get_user_meta($sender_id, 'first_name', true);
$last_name = get_user_meta($sender_id, 'last_name', true);
From 05b9fc3fa55ada1132df7e32de3aa99de188d47d Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 14:57:00 +0530
Subject: [PATCH 025/171] #146 Logic changes
---
includes/rest-api/wpem-rest-matchmaking-user-messages.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/rest-api/wpem-rest-matchmaking-user-messages.php b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
index 87fc107..f792b54 100644
--- a/includes/rest-api/wpem-rest-matchmaking-user-messages.php
+++ b/includes/rest-api/wpem-rest-matchmaking-user-messages.php
@@ -72,7 +72,7 @@ public function handle_send_message($request) {
$wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $receiver_id)
);
- if ($sender_notify !== 1 || $receiver_notify !== 1) {
+ if ($sender_notify != 1 || $receiver_notify != 1) {
return new WP_REST_Response([
'code' => 403,
'status' => 'Forbidden',
From f6aaf1a667e7b2a64a2c4765852938365f32c20e Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 26 May 2025 16:23:59 +0530
Subject: [PATCH 026/171] #164 create Filter Match Making Profiles API
---
.../wpem-rest-matchmaking-filter-users.php | 128 ++++++++++++++++++
wpem-rest-api.php | 3 +-
2 files changed, 130 insertions(+), 1 deletion(-)
create mode 100644 includes/rest-api/wpem-rest-matchmaking-filter-users.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-filter-users.php b/includes/rest-api/wpem-rest-matchmaking-filter-users.php
new file mode 100644
index 0000000..8ab72b6
--- /dev/null
+++ b/includes/rest-api/wpem-rest-matchmaking-filter-users.php
@@ -0,0 +1,128 @@
+namespace, '/' . $this->rest_base, array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'handle_filter_users'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'profession' => array('required' => false, 'type' => 'string'),
+ 'company_name' => array('required' => false, 'type' => 'string'),
+ 'country' => array('required' => false, 'type' => 'array'),
+ 'city' => array('required' => false, 'type' => 'string'),
+ 'experience' => array('required' => false, 'type' => 'integer'), // or 'array' if you want range
+ 'skills' => array('required' => false, 'type' => 'array'),
+ 'interests' => array('required' => false, 'type' => 'array'),
+ ),
+ ));
+ }
+
+ public function handle_filter_users($request) {
+ global $wpdb;
+
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $where_clauses = [];
+ $query_params = [];
+
+ // Profession
+ if ($profession = sanitize_text_field($request->get_param('profession'))) {
+ $where_clauses[] = "profession = %s";
+ $query_params[] = $profession;
+ }
+
+ // Experience (support exact or range)
+ $experience = $request->get_param('experience');
+ if (is_array($experience) && isset($experience['min'], $experience['max'])) {
+ $where_clauses[] = "experience BETWEEN %d AND %d";
+ $query_params[] = (int) $experience['min'];
+ $query_params[] = (int) $experience['max'];
+ } elseif (is_numeric($experience)) {
+ $where_clauses[] = "experience = %d";
+ $query_params[] = (int) $experience;
+ }
+
+ // Company name
+ if ($company = sanitize_text_field($request->get_param('company_name'))) {
+ $where_clauses[] = "company_name = %s";
+ $query_params[] = $company;
+ }
+
+ // Country (string or array)
+ $countries = $request->get_param('country');
+ if (is_array($countries)) {
+ $placeholders = implode(',', array_fill(0, count($countries), '%s'));
+ $where_clauses[] = "country IN ($placeholders)";
+ $query_params = array_merge($query_params, $countries);
+ } elseif (!empty($countries)) {
+ $country = sanitize_text_field($countries);
+ $where_clauses[] = "country = %s";
+ $query_params[] = $country;
+ }
+
+ // City
+ if ($city = sanitize_text_field($request->get_param('city'))) {
+ $where_clauses[] = "city = %s";
+ $query_params[] = $city;
+ }
+
+ // Skills (serialized array match using LIKE)
+ $skills = $request->get_param('skills');
+ if (is_array($skills) && !empty($skills)) {
+ foreach ($skills as $skill) {
+ $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
+ $where_clauses[] = "skills LIKE %s";
+ $query_params[] = $like;
+ }
+ }
+
+ // Interests (serialized array match using LIKE)
+ $interests = $request->get_param('interests');
+ if (is_array($interests) && !empty($interests)) {
+ foreach ($interests as $interest) {
+ $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
+ $where_clauses[] = "interests LIKE %s";
+ $query_params[] = $like;
+ }
+ }
+
+ // Only include approved profiles if required
+ if (get_option('participant_activation') === 'manual') {
+ $where_clauses[] = "approve_profile_status = '1'";
+ }
+
+ $where_sql = implode(' AND ', $where_clauses);
+ $sql = "SELECT * FROM $table WHERE $where_sql";
+
+ $prepared_sql = $wpdb->prepare($sql, $query_params);
+ $results = $wpdb->get_results($prepared_sql, ARRAY_A);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Users retrieved successfully.',
+ 'data' => $results
+ ], 200);
+}
+
+}
+
+new WPEM_REST_Filter_Users_Controller();
+
+?>
\ No newline at end of file
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 7719841..8f088a9 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -69,7 +69,8 @@ public function __construct() {
// match making api
include 'includes/rest-api/wpem-rest-matchmaking-profile.php';
include 'includes/rest-api/wpem-rest-matchmaking-get-texonomy.php';
- include 'includes/rest-api/wpem-rest-matchmaking-user-messages.php';
+ include 'includes/rest-api/wpem-rest-matchmaking-user-messages.php';
+ include 'includes/rest-api/wpem-rest-matchmaking-filter-users-api.php';
// Activate
register_activation_hook( __FILE__, array( $this, 'install' ) );
From ff973f4bfc19d26545e76ba4e716bc41b97c8ea9 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 27 May 2025 13:08:54 +0530
Subject: [PATCH 027/171] #145 Create meeting and get meeting API
---
.../wpem-rest-matchmaking-create-meetings.php | 321 ++++++++++++++++++
wpem-rest-api.php | 1 +
2 files changed, 322 insertions(+)
create mode 100644 includes/rest-api/wpem-rest-matchmaking-create-meetings.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-create-meetings.php b/includes/rest-api/wpem-rest-matchmaking-create-meetings.php
new file mode 100644
index 0000000..05f302b
--- /dev/null
+++ b/includes/rest-api/wpem-rest-matchmaking-create-meetings.php
@@ -0,0 +1,321 @@
+namespace, '/' . $this->rest_base, [
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => [$this, 'create_meeting'],
+ 'permission_callback' => '__return_true',
+ 'args' => [
+ 'user_id' => ['required' => true, 'type' => 'integer'],
+ 'event_id' => ['required' => true, 'type' => 'integer'],
+ 'meeting_date' => ['required' => true, 'type' => 'string'],
+ 'meeting_start_time' => ['required' => true, 'type' => 'string'],
+ 'meeting_end_time' => ['required' => true, 'type' => 'string'],
+ 'meeting_participants' => ['required' => true, 'type' => 'array'],
+ 'write_a_message' => ['required' => false, 'type' => 'string'],
+ ],
+ ]);
+
+ // Get Meetings
+ register_rest_route($this->namespace, '/get-meetings', [
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => [$this, 'get_user_meetings'],
+ 'permission_callback' => '__return_true',
+ ]);
+ }
+
+ public function create_meeting(WP_REST_Request $request) {
+ global $wpdb;
+
+ $user_id = intval($request->get_param('user_id'));
+ $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
+ $start_time = sanitize_text_field($request->get_param('meeting_start_time'));
+ $end_time = sanitize_text_field($request->get_param('meeting_end_time'));
+ $participants = $request->get_param('meeting_participants');
+ $message = sanitize_textarea_field($request->get_param('write_a_message'));
+ $event_id = intval($request->get_param('event_id'));
+
+ if (!$user_id || !get_userdata($user_id)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'Invalid user.',
+ 'data' => []
+ ], 400);
+ }
+
+ if (empty($meeting_date) || empty($start_time) || empty($end_time) || empty($participants) || !is_array($participants)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'Missing or invalid parameters.',
+ 'data' => []
+ ], 400);
+ }
+
+ // Remove self from participants
+ $participants = array_filter(array_map('intval', $participants), function ($pid) use ($user_id) {
+ return $pid !== $user_id;
+ });
+
+ $meeting_table_name = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $inserted = $wpdb->insert(
+ $meeting_table_name,
+ [
+ 'user_id' => $user_id,
+ 'event_id' => $event_id,
+ 'participant_ids' => implode(',', $participants),
+ 'meeting_date' => $meeting_date,
+ 'meeting_start_time' => $start_time,
+ 'meeting_end_time' => $end_time,
+ 'message' => $message,
+ 'meeting_status' => 0
+ ],
+ ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']
+ );
+
+ if (!$inserted) {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Internal Server Error',
+ 'message' => 'Could not create meeting. Please try again.',
+ 'data' => []
+ ], 500);
+ }
+
+ $meeting_id = $wpdb->insert_id;
+
+ $formatted_date = date("l, d F Y", strtotime($meeting_date));
+ $formatted_start_time = date("h:i A", strtotime($start_time));
+ $formatted_end_time = date("h:i A", strtotime($end_time));
+
+ $participant_details = [];
+ $sender_user = get_userdata($user_id);
+
+ if (!empty($participants)) {
+ $table_name = $wpdb->prefix . 'wpem_matchmaking_users';
+ $placeholders = implode(',', array_fill(0, count($participants), '%d'));
+ $query = $wpdb->prepare("SELECT * FROM $table_name WHERE user_id IN ($placeholders)", ...$participants);
+ $results = $wpdb->get_results($query, ARRAY_A);
+
+ foreach ($results as $participant) {
+ $user_data = get_userdata($participant['user_id']);
+ $profile_picture_url = $participant['profile_photo'] ?? '';
+ if (empty($profile_picture_url)) {
+ $profile_picture_url = EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
+ }
+
+ $participant_details[] = [
+ 'name' => $user_data ? $user_data->display_name : '',
+ 'profession' => $participant['profession'] ?? '',
+ 'profile_picture' => $profile_picture_url
+ ];
+
+ // Email to participant
+ $token = wp_create_nonce("meeting_action_{$meeting_id}_{$participant['user_id']}");
+ $confirm_url = add_query_arg([
+ 'meeting_action' => 'confirm',
+ 'meeting_id' => $meeting_id,
+ 'user_id' => $participant['user_id'],
+ 'token' => $token,
+ ], home_url('/'));
+
+ $decline_url = add_query_arg([
+ 'meeting_action' => 'decline',
+ 'meeting_id' => $meeting_id,
+ 'user_id' => $participant['user_id'],
+ 'token' => $token,
+ ], home_url('/'));
+
+ $host_profile = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d", $user_id), ARRAY_A);
+ $host_company = $host_profile['company_name'] ?? '';
+ $host_city = $host_profile['city'] ?? '';
+ $all_countries = wpem_registration_get_all_countries();
+ $host_country = $all_countries[$host_profile['country']] ?? '';
+ $event_name = ''; // You can pull this dynamically if needed
+ $timezone_abbr = wp_timezone_string();
+
+ $subject = "{$sender_user->display_name} requested a meeting with you";
+ $body = "
+ Hello {$user_data->display_name},
+ {$sender_user->display_name} has requested a meeting with you.
+ Event: {$event_name}
+ Date: {$formatted_date}
+ Time: {$formatted_start_time} – {$formatted_end_time} {$timezone_abbr}
+ Company: {$host_company}
+ City: {$host_city}
+ Country: {$host_country}
+ Message: {$message}
+
+ Confirm |
+ Decline
+
+ ";
+
+ wp_mail($user_data->user_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
+ }
+ }
+
+ // Email to sender
+ $participant_names = implode(', ', array_column($participant_details, 'name'));
+ $cancel_token = wp_create_nonce("cancel_meeting_{$meeting_id}_{$user_id}");
+ $cancel_url = add_query_arg([
+ 'meeting_action' => 'cancel',
+ 'meeting_id' => $meeting_id,
+ 'user_id' => $user_id,
+ 'token' => $cancel_token,
+ ], home_url('/'));
+
+ wp_mail(
+ $sender_user->user_email,
+ 'Your Meeting Request Has Been Sent',
+ "
+ Hello {$sender_user->display_name},
+ Your meeting request has been sent to: {$participant_names} .
+ Date: {$formatted_date}
+ Time: {$formatted_start_time} - {$formatted_end_time}
+ Message: {$message}
+ Cancel Meeting
+ ",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
+
+ // Final Success Response
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meeting created and emails sent!',
+ 'data' => [
+ 'meeting_date' => $formatted_date,
+ 'start_time' => $formatted_start_time,
+ 'end_time' => $formatted_end_time,
+ 'participants' => $participant_details,
+ 'message' => $message
+ ]
+ ], 200);
+ }
+
+ public function get_user_meetings(WP_REST_Request $request) {
+ global $wpdb;
+
+ $event_id = $request->get_param('event_id');
+ $user_id = intval($request->get_param('user_id'));
+ $participants_id = $request->get_param('participants_id');
+
+ if (!$event_id || !$user_id || empty($participants_id)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'error',
+ 'message' => 'Missing event_id, user_id, or participants_id.',
+ 'data' => null,
+ ], 400);
+ }
+
+ // Normalize participants_id as array
+ if (!is_array($participants_id)) {
+ $participants_id = array_map('intval', explode(',', $participants_id));
+ }
+
+ // Build dynamic FIND_IN_SET conditions
+ $conditions = [];
+ foreach ($participants_id as $id) {
+ $conditions[] = $wpdb->prepare("FIND_IN_SET(%d, participant_ids)", $id);
+ }
+ $where_participants = implode(" OR ", $conditions);
+
+ // Query all matching meetings
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $sql = "
+ SELECT * FROM $table
+ WHERE event_id = %d
+ AND user_id = %d
+ AND ($where_participants)
+ ";
+ $query = $wpdb->prepare($sql, $event_id, $user_id);
+ $meetings = $wpdb->get_results($query, ARRAY_A);
+
+ if (empty($meetings)) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'error',
+ 'message' => 'No meetings found for the given input.',
+ 'data' => null,
+ ], 404);
+ }
+
+ // Collect all unique user IDs involved (host + participants)
+ $all_user_ids = [$user_id];
+ foreach ($meetings as $meeting) {
+ $ids = array_map('intval', explode(',', $meeting['participant_ids']));
+ $all_user_ids = array_merge($all_user_ids, $ids);
+ }
+ $all_user_ids = array_unique($all_user_ids);
+
+ // Fetch data from custom matchmaking user table
+ $custom_user_data = $wpdb->get_results(
+ $wpdb->prepare(
+ "SELECT user_id, profession, profile_photo FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id IN (" . implode(',', array_fill(0, count($all_user_ids), '%d')) . ")",
+ ...$all_user_ids
+ ),
+ ARRAY_A
+ );
+ $custom_user_indexed = [];
+ foreach ($custom_user_data as $u) {
+ $custom_user_indexed[$u['user_id']] = $u;
+ }
+
+ // Helper to get user info
+ $get_user_info = function($uid) use ($custom_user_indexed) {
+ $first_name = get_user_meta($uid, 'first_name', true);
+ $last_name = get_user_meta($uid, 'last_name', true);
+ return [
+ 'user_id' => $uid,
+ 'name' => trim("$first_name $last_name") ?: 'Unknown',
+ 'profession' => $custom_user_indexed[$uid]['profession'] ?? '',
+ 'profile_picture' => esc_url($custom_user_indexed[$uid]['profile_photo'] ?? ''),
+ ];
+ };
+
+ // Final meetings list
+ $meeting_data = [];
+
+ foreach ($meetings as $meeting) {
+ $participant_ids = array_map('intval', explode(',', $meeting['participant_ids']));
+ $participants_info = [];
+
+ foreach ($participant_ids as $pid) {
+ if ($pid !== $user_id) {
+ $participants_info[] = $get_user_info($pid);
+ }
+ }
+
+ $meeting_data[] = [
+ 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
+ 'start_time' => date_i18n('h:i A', strtotime($meeting['start_time'])),
+ 'end_time' => date_i18n('h:i A', strtotime($meeting['end_time'])),
+ 'message' => $meeting['message'] ?? '',
+ 'host' => $get_user_info($user_id),
+ 'participants' => $participants_info,
+ ];
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meetings retrieved successfully.',
+ 'data' => $meeting_data,
+ ], 200);
+ }
+}
+
+new WPEM_REST_Create_Meeting_Controller();
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 8f088a9..8ac1623 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -71,6 +71,7 @@ public function __construct() {
include 'includes/rest-api/wpem-rest-matchmaking-get-texonomy.php';
include 'includes/rest-api/wpem-rest-matchmaking-user-messages.php';
include 'includes/rest-api/wpem-rest-matchmaking-filter-users-api.php';
+ include 'includes/rest-api/wpem-rest-matchmaking-create-meetings.php';
// Activate
register_activation_hook( __FILE__, array( $this, 'install' ) );
From 4a65bee14734e78bfec3e7cbb3542c44f3b7da22 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 27 May 2025 13:12:07 +0530
Subject: [PATCH 028/171] #145 Add validation
---
.../wpem-rest-matchmaking-create-meetings.php | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/includes/rest-api/wpem-rest-matchmaking-create-meetings.php b/includes/rest-api/wpem-rest-matchmaking-create-meetings.php
index 05f302b..492de4b 100644
--- a/includes/rest-api/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/rest-api/wpem-rest-matchmaking-create-meetings.php
@@ -35,6 +35,14 @@ public function register_routes() {
}
public function create_meeting(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
global $wpdb;
$user_id = intval($request->get_param('user_id'));
@@ -206,6 +214,14 @@ public function create_meeting(WP_REST_Request $request) {
}
public function get_user_meetings(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
global $wpdb;
$event_id = $request->get_param('event_id');
From cafccae49bde70c788a1b881a2a191f0fe957be0 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 27 May 2025 16:01:18 +0530
Subject: [PATCH 029/171] #147 change array format
---
includes/rest-api/wpem-rest-matchmaking-profile.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/rest-api/wpem-rest-matchmaking-profile.php b/includes/rest-api/wpem-rest-matchmaking-profile.php
index de51d6a..3db7a26 100644
--- a/includes/rest-api/wpem-rest-matchmaking-profile.php
+++ b/includes/rest-api/wpem-rest-matchmaking-profile.php
@@ -88,8 +88,8 @@ private function format_profile_data($data) {
'country' => $data['country'],
'city' => $data['city'],
'about' => $data['about'],
- 'skills' => $data['skills'],
- 'interests' => $data['interests'],
+ 'skills' => maybe_unserialize($data['skills']),
+ 'interests' => maybe_unserialize($data['interests']),
'organizationName' => $data['organization_name'],
'organizationLogo' => $data['organization_logo'],
'organizationCity' => $data['organization_city'],
From 84b719229613e224c7b4922dad650cfefc465354 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 28 May 2025 10:30:45 +0530
Subject: [PATCH 030/171] #164 Your Matches api
---
.../wpem-rest-matchmaking-filter-users.php | 250 ++++++++++++------
1 file changed, 162 insertions(+), 88 deletions(-)
diff --git a/includes/rest-api/wpem-rest-matchmaking-filter-users.php b/includes/rest-api/wpem-rest-matchmaking-filter-users.php
index 8ab72b6..49daa3b 100644
--- a/includes/rest-api/wpem-rest-matchmaking-filter-users.php
+++ b/includes/rest-api/wpem-rest-matchmaking-filter-users.php
@@ -1,4 +1,4 @@
-namespace, '/' . $this->rest_base, array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'handle_filter_users'),
'permission_callback' => '__return_true',
'args' => array(
'profession' => array('required' => false, 'type' => 'string'),
- 'company_name' => array('required' => false, 'type' => 'string'),
- 'country' => array('required' => false, 'type' => 'array'),
- 'city' => array('required' => false, 'type' => 'string'),
- 'experience' => array('required' => false, 'type' => 'integer'), // or 'array' if you want range
- 'skills' => array('required' => false, 'type' => 'array'),
- 'interests' => array('required' => false, 'type' => 'array'),
+ 'company_name' => array('required' => false, 'type' => 'string'),
+ 'country' => array('required' => false, 'type' => 'array'),
+ 'city' => array('required' => false, 'type' => 'string'),
+ 'experience' => array('required' => false),
+ 'skills' => array('required' => false, 'type' => 'array'),
+ 'interests' => array('required' => false, 'type' => 'array'),
+ ),
+ ));
+
+ // Your matches (with optional user_id param)
+ register_rest_route($this->namespace, '/your-matches', array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'handle_your_matches'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'user_id' => array('required' => false, 'type' => 'integer'),
),
));
}
- public function handle_filter_users($request) {
- global $wpdb;
+ public function handle_your_matches($request) {
+ global $wpdb;
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $where_clauses = [];
- $query_params = [];
+ $user_id = intval($request->get_param('user_id'));
+ if (!$user_id) {
+ $user_id = get_current_user_id();
+ }
- // Profession
- if ($profession = sanitize_text_field($request->get_param('profession'))) {
- $where_clauses[] = "profession = %s";
- $query_params[] = $profession;
- }
+ if (!$user_id) {
+ return new WP_REST_Response([
+ 'code' => 401,
+ 'status' => 'Unauthorized',
+ 'message' => 'User not logged in or user_id not provided'
+ ], 401);
+ }
- // Experience (support exact or range)
- $experience = $request->get_param('experience');
- if (is_array($experience) && isset($experience['min'], $experience['max'])) {
- $where_clauses[] = "experience BETWEEN %d AND %d";
- $query_params[] = (int) $experience['min'];
- $query_params[] = (int) $experience['max'];
- } elseif (is_numeric($experience)) {
- $where_clauses[] = "experience = %d";
- $query_params[] = (int) $experience;
- }
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $user_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id), ARRAY_A);
- // Company name
- if ($company = sanitize_text_field($request->get_param('company_name'))) {
- $where_clauses[] = "company_name = %s";
- $query_params[] = $company;
- }
+ if (!$user_data) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'Matchmaking profile not found for user'
+ ], 404);
+ }
- // Country (string or array)
- $countries = $request->get_param('country');
- if (is_array($countries)) {
- $placeholders = implode(',', array_fill(0, count($countries), '%s'));
- $where_clauses[] = "country IN ($placeholders)";
- $query_params = array_merge($query_params, $countries);
- } elseif (!empty($countries)) {
- $country = sanitize_text_field($countries);
- $where_clauses[] = "country = %s";
- $query_params[] = $country;
- }
+ // Build a filter request based on user's profile
+ $filter_request = new WP_REST_Request('GET');
+ $filter_request->set_param('profession', $user_data['profession']);
+ $filter_request->set_param('company_name', $user_data['company_name']);
+ $filter_request->set_param('country', [$user_data['country']]);
+ $filter_request->set_param('city', $user_data['city']);
+
+ $exp = (int)$user_data['experience'];
+ $filter_request->set_param('experience', [
+ 'min' => max(0, $exp - 2),
+ 'max' => $exp + 2
+ ]);
+
+ $skills = maybe_unserialize($user_data['skills']);
+ if (is_array($skills)) {
+ $filter_request->set_param('skills', $skills);
+ }
- // City
- if ($city = sanitize_text_field($request->get_param('city'))) {
- $where_clauses[] = "city = %s";
- $query_params[] = $city;
- }
+ $interests = maybe_unserialize($user_data['interests']);
+ if (is_array($interests)) {
+ $filter_request->set_param('interests', $interests);
+ }
+
+ // Reuse the filter handler
+ $response = $this->handle_filter_users($filter_request);
- // Skills (serialized array match using LIKE)
- $skills = $request->get_param('skills');
- if (is_array($skills) && !empty($skills)) {
- foreach ($skills as $skill) {
- $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
- $where_clauses[] = "skills LIKE %s";
- $query_params[] = $like;
+ // Exclude the user from their own matches
+ if ($response instanceof WP_REST_Response) {
+ $data = $response->get_data();
+ $data['data'] = array_values(array_filter($data['data'], function ($item) use ($user_id) {
+ return $item['user_id'] != $user_id;
+ }));
+ $response->set_data($data);
}
+
+ return $response;
}
- // Interests (serialized array match using LIKE)
- $interests = $request->get_param('interests');
- if (is_array($interests) && !empty($interests)) {
- foreach ($interests as $interest) {
- $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
- $where_clauses[] = "interests LIKE %s";
- $query_params[] = $like;
+ public function handle_filter_users($request) {
+ global $wpdb;
+
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
}
- }
- // Only include approved profiles if required
- if (get_option('participant_activation') === 'manual') {
- $where_clauses[] = "approve_profile_status = '1'";
- }
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $where_clauses = [];
+ $query_params = [];
- $where_sql = implode(' AND ', $where_clauses);
- $sql = "SELECT * FROM $table WHERE $where_sql";
+ if ($profession = sanitize_text_field($request->get_param('profession'))) {
+ $where_clauses[] = "profession = %s";
+ $query_params[] = $profession;
+ }
- $prepared_sql = $wpdb->prepare($sql, $query_params);
- $results = $wpdb->get_results($prepared_sql, ARRAY_A);
+ $experience = $request->get_param('experience');
+ if (is_array($experience) && isset($experience['min'], $experience['max'])) {
+ $where_clauses[] = "experience BETWEEN %d AND %d";
+ $query_params[] = (int)$experience['min'];
+ $query_params[] = (int)$experience['max'];
+ } elseif (is_numeric($experience)) {
+ $where_clauses[] = "experience = %d";
+ $query_params[] = (int)$experience;
+ }
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Users retrieved successfully.',
- 'data' => $results
- ], 200);
-}
+ if ($company = sanitize_text_field($request->get_param('company_name'))) {
+ $where_clauses[] = "company_name = %s";
+ $query_params[] = $company;
+ }
+ $countries = $request->get_param('country');
+ if (is_array($countries)) {
+ $placeholders = implode(',', array_fill(0, count($countries), '%s'));
+ $where_clauses[] = "country IN ($placeholders)";
+ $query_params = array_merge($query_params, array_map('sanitize_text_field', $countries));
+ } elseif (!empty($countries)) {
+ $country = sanitize_text_field($countries);
+ $where_clauses[] = "country = %s";
+ $query_params[] = $country;
+ }
+
+ if ($city = sanitize_text_field($request->get_param('city'))) {
+ $where_clauses[] = "city = %s";
+ $query_params[] = $city;
+ }
+
+ $skills = $request->get_param('skills');
+ if (is_array($skills) && !empty($skills)) {
+ foreach ($skills as $skill) {
+ $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
+ $where_clauses[] = "skills LIKE %s";
+ $query_params[] = $like;
+ }
+ }
+
+ $interests = $request->get_param('interests');
+ if (is_array($interests) && !empty($interests)) {
+ foreach ($interests as $interest) {
+ $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
+ $where_clauses[] = "interests LIKE %s";
+ $query_params[] = $like;
+ }
+ }
+
+ if (get_option('participant_activation') === 'manual') {
+ $where_clauses[] = "approve_profile_status = '1'";
+ }
+
+ $where_sql = $where_clauses ? 'WHERE ' . implode(' AND ', $where_clauses) : '';
+ $sql = "SELECT * FROM $table $where_sql";
+
+ $prepared_sql = $wpdb->prepare($sql, $query_params);
+ $results = $wpdb->get_results($prepared_sql, ARRAY_A);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Users retrieved successfully.',
+ 'data' => $results
+ ], 200);
+ }
}
new WPEM_REST_Filter_Users_Controller();
-
-?>
\ No newline at end of file
From 55dc233f0276f29c259ea1434b3cce8b12cd318c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 28 May 2025 10:39:37 +0530
Subject: [PATCH 031/171] #160 Get user's registered event
---
...rest-matchmaking-user-registred-events.php | 89 +++++++++++++++++++
wpem-rest-api.php | 1 +
2 files changed, 90 insertions(+)
create mode 100644 includes/rest-api/wpem-rest-matchmaking-user-registred-events.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-user-registred-events.php b/includes/rest-api/wpem-rest-matchmaking-user-registred-events.php
new file mode 100644
index 0000000..7cbf56c
--- /dev/null
+++ b/includes/rest-api/wpem-rest-matchmaking-user-registred-events.php
@@ -0,0 +1,89 @@
+namespace,
+ '/' . $this->rest_base,
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'get_user_registered_events'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'user_id' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ 'description' => 'User ID to fetch registered events for.'
+ )
+ )
+ )
+ );
+ }
+
+ public function get_user_registered_events($request) {
+ $target_user_id = intval($request->get_param('user_id'));
+
+ $args = array(
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'post_status' => 'any',
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => '_attendee_user_id',
+ 'value' => $target_user_id,
+ )
+ ),
+ );
+
+ $query = new WP_Query($args);
+ $event_ids = array();
+
+ foreach ($query->posts as $registration_id) {
+ $event_id = get_post_meta($registration_id, '_event_id', true);
+ if (!empty($event_id) && !in_array($event_id, $event_ids)) {
+ $event_ids[] = (int) $event_id;
+ }
+ }
+
+ if (empty($event_ids)) {
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No registered events found.',
+ 'data' => []
+ ), 200);
+ }
+
+ $events = array();
+ foreach ($event_ids as $event_id) {
+ $post = get_post($event_id);
+ if ($post && $post->post_type === 'event_listing') {
+ $events[] = array(
+ 'event_id' => $event_id,
+ 'title' => get_the_title($event_id),
+ 'status' => $post->post_status,
+ 'start_date' => get_post_meta($event_id, '_event_start_date', true),
+ 'end_date' => get_post_meta($event_id, '_event_end_date', true),
+ 'location' => get_post_meta($event_id, '_event_location', true),
+ );
+ }
+ }
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Events retrieved successfully.',
+ 'data' => $events
+ ), 200);
+ }
+}
+
+new WPEM_REST_User_Registered_Events_Controller();
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 8ac1623..f66d937 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -72,6 +72,7 @@ public function __construct() {
include 'includes/rest-api/wpem-rest-matchmaking-user-messages.php';
include 'includes/rest-api/wpem-rest-matchmaking-filter-users-api.php';
include 'includes/rest-api/wpem-rest-matchmaking-create-meetings.php';
+ include 'includes/rest-api/wpem-rest-matchmaking-user-registred-events.php';
// Activate
register_activation_hook( __FILE__, array( $this, 'install' ) );
From 3a1bfce53392ce9395ecf3acffef613f78a43f55 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 28 May 2025 13:14:04 +0530
Subject: [PATCH 032/171] #165 Upload Image Api for profile picture for
attendee match making
---
.../wpem-rest-matchmaking-profile.php | 224 ++++++++++++------
1 file changed, 154 insertions(+), 70 deletions(-)
diff --git a/includes/rest-api/wpem-rest-matchmaking-profile.php b/includes/rest-api/wpem-rest-matchmaking-profile.php
index 3db7a26..02912e8 100644
--- a/includes/rest-api/wpem-rest-matchmaking-profile.php
+++ b/includes/rest-api/wpem-rest-matchmaking-profile.php
@@ -1,12 +1,8 @@
namespace,
- '/' . $this->rest_base,
+ '/attendee-profile',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'get_attendee_profile'),
@@ -28,6 +24,38 @@ public function register_routes() {
),
)
);
+
+ register_rest_route(
+ $this->namespace,
+ '/attendee-profile/update',
+ array(
+ 'methods' => WP_REST_Server::EDITABLE,
+ 'callback' => array($this, 'update_attendee_profile'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'user_id' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ ),
+ ),
+ )
+ );
+
+ register_rest_route(
+ $this->namespace,
+ '/upload-user-file',
+ array(
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array($this, 'upload_user_file'),
+ 'permission_callback' => '__return_true',
+ 'args' => array(
+ 'user_id' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ ),
+ ),
+ )
+ );
}
public function get_attendee_profile($request) {
@@ -73,64 +101,9 @@ public function get_attendee_profile($request) {
}
}
- private function format_profile_data($data) {
- $user = get_userdata($data['user_id']);
-
- return array(
- 'attendeeId' => $data['user_id'],
- 'firstName' => $user ? get_user_meta($user->ID, 'first_name', true) : '',
- 'lastName' => $user ? get_user_meta($user->ID, 'last_name', true) : '',
- 'email' => $user ? $user->user_email : '',
- 'profilePhoto' => $data['profile_photo'],
- 'profession' => $data['profession'],
- 'experience' => $data['experience'],
- 'companyName' => $data['company_name'],
- 'country' => $data['country'],
- 'city' => $data['city'],
- 'about' => $data['about'],
- 'skills' => maybe_unserialize($data['skills']),
- 'interests' => maybe_unserialize($data['interests']),
- 'organizationName' => $data['organization_name'],
- 'organizationLogo' => $data['organization_logo'],
- 'organizationCity' => $data['organization_city'],
- 'organizationCountry' => $data['organization_country'],
- 'organizationDescription' => $data['organization_description'],
- 'messageNotification' => $data['message_notification'],
- 'approveProfileStatus' => $data['approve_profile_status'],
- );
- }
-}
-
-
-/**
- * REST API Attendee Profile UPDATE controller class.
- */
-class WPEM_REST_Attendee_Profile_Update_Controller {
- protected $namespace = 'wpem';
- protected $rest_base = 'attendee-profile';
-
- public function __construct() {
- add_action('rest_api_init', array($this, 'register_routes'), 10);
- }
-
- public function register_routes() {
- register_rest_route(
- $this->namespace,
- '/' . $this->rest_base . '/update',
- array(
- 'methods' => WP_REST_Server::EDITABLE,
- 'callback' => array($this, 'update_attendee_profile'),
- 'permission_callback' => '__return_true',
- 'args' => array(
- 'user_id' => array(
- 'required' => true,
- 'type' => 'integer',
- ),
- ),
- )
- );
- }
-
+ /**
+ * Update profile including handling file upload from device for profile_photo
+ */
public function update_attendee_profile($request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
@@ -155,16 +128,42 @@ public function update_attendee_profile($request) {
}
$custom_fields = [
- 'profile_photo', 'profession', 'experience', 'company_name', 'country',
+ 'profession', 'experience', 'company_name', 'country',
'city', 'about', 'skills', 'interests', 'organization_name', 'organization_logo',
'organization_city', 'organization_country', 'organization_description',
'message_notification', 'approve_profile_status',
];
$custom_data = [];
+
+ // Handle normal fields
foreach ($custom_fields as $field) {
if ($request->get_param($field) !== null) {
- $custom_data[$field] = sanitize_text_field($request->get_param($field));
+ $value = $request->get_param($field);
+ $custom_data[$field] = sanitize_text_field($value);
+ }
+ }
+
+ // Handle profile_photo file upload if present in $_FILES
+ if (!empty($_FILES['profile_photo']) && $_FILES['profile_photo']['error'] === UPLOAD_ERR_OK) {
+ require_once ABSPATH . 'wp-admin/includes/file.php';
+ $upload_overrides = array('test_form' => false);
+
+ $movefile = wp_handle_upload($_FILES['profile_photo'], $upload_overrides);
+
+ if (isset($movefile['url'])) {
+ $profile_photo_url = esc_url_raw($movefile['url']);
+ $custom_data['profile_photo'] = $profile_photo_url;
+ update_user_meta($user_id, '_profile_photo', $profile_photo_url);
+ } else {
+ return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Profile photo upload failed.'], 500);
+ }
+ } else {
+ // If no file, but profile_photo is sent as URL string, update that
+ if ($request->get_param('profile_photo') !== null) {
+ $profile_photo_url = esc_url_raw($request->get_param('profile_photo'));
+ $custom_data['profile_photo'] = $profile_photo_url;
+ update_user_meta($user_id, '_profile_photo', $profile_photo_url);
}
}
@@ -175,6 +174,7 @@ public function update_attendee_profile($request) {
}
}
+ // Update basic WP user fields
if ($first = $request->get_param('first_name')) {
update_user_meta($user_id, 'first_name', sanitize_text_field($first));
}
@@ -195,8 +195,92 @@ public function update_attendee_profile($request) {
return new WP_REST_Response(['code' => 200, 'status' => 'OK', 'message' => 'Profile updated successfully.'], 200);
}
-}
-// Initialize both controllers
-new WPEM_REST_Attendee_Profile_Controller();
-new WPEM_REST_Attendee_Profile_Update_Controller();
+ public function upload_user_file($request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.'
+ ], 403);
+ }
+
+ $user_id = $request->get_param('user_id');
+ $user = get_user_by('id', $user_id);
+ if (!$user) {
+ return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'User not found.'], 404);
+ }
+
+ if (empty($_FILES['file'])) {
+ return new WP_REST_Response(['code' => 400, 'status' => 'Error', 'message' => 'No file uploaded.'], 400);
+ }
+
+ require_once ABSPATH . 'wp-admin/includes/file.php';
+
+ $file = $_FILES['file'];
+ $upload_overrides = array('test_form' => false);
+
+ $movefile = wp_handle_upload($file, $upload_overrides);
+
+ if (!isset($movefile['url'])) {
+ return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'File upload failed.'], 500);
+ }
+
+ $file_url = esc_url_raw($movefile['url']);
+
+ global $wpdb;
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
+ if (!$existing) {
+ return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'Profile not found.'], 404);
+ }
+
+ $updated = $wpdb->update(
+ $table,
+ ['profile_photo' => $file_url],
+ ['user_id' => $user_id]
+ );
+
+ if ($updated === false) {
+ return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Failed to update file URL in table.'], 500);
+ }
+
+ update_user_meta($user_id, '_profile_photo', $file_url);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'File uploaded and stored successfully.',
+ 'data' => ['file_url' => $file_url]
+ ], 200);
+ }
+
+ private function format_profile_data($data) {
+ $user = get_userdata($data['user_id']);
+
+ return array(
+ 'attendeeId' => $data['user_id'],
+ 'firstName' => $user ? get_user_meta($user->ID, 'first_name', true) : '',
+ 'lastName' => $user ? get_user_meta($user->ID, 'last_name', true) : '',
+ 'email' => $user ? $user->user_email : '',
+ 'profilePhoto' => $data['profile_photo'],
+ 'profession' => $data['profession'],
+ 'experience' => $data['experience'],
+ 'companyName' => $data['company_name'],
+ 'country' => $data['country'],
+ 'city' => $data['city'],
+ 'about' => $data['about'],
+ 'skills' => maybe_unserialize($data['skills']),
+ 'interests' => maybe_unserialize($data['interests']),
+ 'organizationName' => $data['organization_name'],
+ 'organizationLogo' => $data['organization_logo'],
+ 'organizationCity' => $data['organization_city'],
+ 'organizationCountry' => $data['organization_country'],
+ 'organizationDescription' => $data['organization_description'],
+ 'messageNotification' => $data['message_notification'],
+ 'approveProfileStatus' => $data['approve_profile_status'],
+ );
+ }
+}
+new WPEM_REST_Attendee_Profile_Controller_All();
From 9c4cbf3f210b5dd209654bc305334c4bc3ebfd81 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 28 May 2025 14:27:34 +0530
Subject: [PATCH 033/171] #147 file name correction
---
wpem-rest-api.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index f66d937..3d14a69 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -70,7 +70,7 @@ public function __construct() {
include 'includes/rest-api/wpem-rest-matchmaking-profile.php';
include 'includes/rest-api/wpem-rest-matchmaking-get-texonomy.php';
include 'includes/rest-api/wpem-rest-matchmaking-user-messages.php';
- include 'includes/rest-api/wpem-rest-matchmaking-filter-users-api.php';
+ include 'includes/rest-api/wpem-rest-matchmaking-filter-users.php';
include 'includes/rest-api/wpem-rest-matchmaking-create-meetings.php';
include 'includes/rest-api/wpem-rest-matchmaking-user-registred-events.php';
From 1e97274394ca1e8c54f4d5bb189fe5ffb0e91324 Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Thu, 29 May 2025 17:00:52 +0530
Subject: [PATCH 034/171] In some server, app is not working because of
authentication issue #166
---
.../rest-api/wpem-rest-crud-controller.php | 18 +++++++++++++++---
wpem-rest-api-functions.php | 16 ++++++++++++++--
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/includes/rest-api/wpem-rest-crud-controller.php b/includes/rest-api/wpem-rest-crud-controller.php
index 6f0ba57..8733191 100644
--- a/includes/rest-api/wpem-rest-crud-controller.php
+++ b/includes/rest-api/wpem-rest-crud-controller.php
@@ -652,10 +652,22 @@ public function wpem_check_authorized_user() {
// Get the authorization header
global $wpdb;
$headers = getallheaders();
- $token = isset($headers['Authorization']) ? trim(str_replace('Bearer', '', $headers['Authorization'])) : '';
-
+ $token = '';
+
+ // First try standard header
+ if (isset($headers['Authorization'])) {
+ $token = trim(str_replace('Bearer', '', $headers['Authorization']));
+ }
+ // Try for some server environments
+ elseif (isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ $token = trim(str_replace('Bearer', '', $_SERVER['HTTP_AUTHORIZATION']));
+ }
+ // NGINX or fastcgi_pass may use this
+ elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
+ $token = trim(str_replace('Bearer', '', $_SERVER['REDIRECT_HTTP_AUTHORIZATION']));
+ }
if(empty($token)) {
- return self::prepare_error_for_response(405);
+ return WPEM_REST_CRUD_Controller::prepare_error_for_response(405);
}
$user_data = self::wpem_validate_jwt_token($token);
diff --git a/wpem-rest-api-functions.php b/wpem-rest-api-functions.php
index abd4b71..a3096fa 100644
--- a/wpem-rest-api-functions.php
+++ b/wpem-rest-api-functions.php
@@ -402,8 +402,20 @@ function get_wpem_event_users() {
function wpem_rest_get_current_user_id(){
// Get the authorization header
$headers = getallheaders();
- $token = isset($headers['Authorization']) ? trim(str_replace('Bearer', '', $headers['Authorization'])) : '';
-
+ $token = '';
+
+ // First try standard header
+ if (isset($headers['Authorization'])) {
+ $token = trim(str_replace('Bearer', '', $headers['Authorization']));
+ }
+ // Try for some server environments
+ elseif (isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ $token = trim(str_replace('Bearer', '', $_SERVER['HTTP_AUTHORIZATION']));
+ }
+ // NGINX or fastcgi_pass may use this
+ elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
+ $token = trim(str_replace('Bearer', '', $_SERVER['REDIRECT_HTTP_AUTHORIZATION']));
+ }
if(empty($token)) {
return WPEM_REST_CRUD_Controller::prepare_error_for_response(401);
}
From 7de01dcec165dd4de4ecf8abb98e980386c65bd5 Mon Sep 17 00:00:00 2001
From: Rita Kikani
Date: Thu, 29 May 2025 17:16:42 +0530
Subject: [PATCH 035/171] =?UTF-8?q?Need=20to=20change=20name=20from=20"WPE?=
=?UTF-8?q?M=20=E2=80=93=20REST=20API".=20-->.=20WP=20Event=20Manager=20-?=
=?UTF-8?q?=20REST=20API=20#163?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../{rest-api => }/wpem-rest-app-branding.php | 0
.../wpem-rest-authentication.php | 0
.../{rest-api => }/wpem-rest-conroller.php | 0
.../wpem-rest-crud-controller.php | 0
.../wpem-rest-ecosystem-controller.php | 0
.../wpem-rest-events-controller.php | 0
.../wpem-rest-matchmaking-create-meetings.php | 0
.../wpem-rest-matchmaking-filter-users.php | 0
.../wpem-rest-matchmaking-get-texonomy.php | 0
.../wpem-rest-matchmaking-profile.php | 0
.../wpem-rest-matchmaking-user-messages.php | 0
...rest-matchmaking-user-registred-events.php | 0
.../wpem-rest-organizers-controller.php | 0
.../wpem-rest-posts-conroller.php | 0
.../wpem-rest-venues-controller.php | 0
readme.txt | 2 +-
wpem-rest-api.php | 28 +++++++++----------
17 files changed, 15 insertions(+), 15 deletions(-)
rename includes/{rest-api => }/wpem-rest-app-branding.php (100%)
rename includes/{rest-api => }/wpem-rest-authentication.php (100%)
rename includes/{rest-api => }/wpem-rest-conroller.php (100%)
rename includes/{rest-api => }/wpem-rest-crud-controller.php (100%)
rename includes/{rest-api => }/wpem-rest-ecosystem-controller.php (100%)
rename includes/{rest-api => }/wpem-rest-events-controller.php (100%)
rename includes/{rest-api => }/wpem-rest-matchmaking-create-meetings.php (100%)
rename includes/{rest-api => }/wpem-rest-matchmaking-filter-users.php (100%)
rename includes/{rest-api => }/wpem-rest-matchmaking-get-texonomy.php (100%)
rename includes/{rest-api => }/wpem-rest-matchmaking-profile.php (100%)
rename includes/{rest-api => }/wpem-rest-matchmaking-user-messages.php (100%)
rename includes/{rest-api => }/wpem-rest-matchmaking-user-registred-events.php (100%)
rename includes/{rest-api => }/wpem-rest-organizers-controller.php (100%)
rename includes/{rest-api => }/wpem-rest-posts-conroller.php (100%)
rename includes/{rest-api => }/wpem-rest-venues-controller.php (100%)
diff --git a/includes/rest-api/wpem-rest-app-branding.php b/includes/wpem-rest-app-branding.php
similarity index 100%
rename from includes/rest-api/wpem-rest-app-branding.php
rename to includes/wpem-rest-app-branding.php
diff --git a/includes/rest-api/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
similarity index 100%
rename from includes/rest-api/wpem-rest-authentication.php
rename to includes/wpem-rest-authentication.php
diff --git a/includes/rest-api/wpem-rest-conroller.php b/includes/wpem-rest-conroller.php
similarity index 100%
rename from includes/rest-api/wpem-rest-conroller.php
rename to includes/wpem-rest-conroller.php
diff --git a/includes/rest-api/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
similarity index 100%
rename from includes/rest-api/wpem-rest-crud-controller.php
rename to includes/wpem-rest-crud-controller.php
diff --git a/includes/rest-api/wpem-rest-ecosystem-controller.php b/includes/wpem-rest-ecosystem-controller.php
similarity index 100%
rename from includes/rest-api/wpem-rest-ecosystem-controller.php
rename to includes/wpem-rest-ecosystem-controller.php
diff --git a/includes/rest-api/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
similarity index 100%
rename from includes/rest-api/wpem-rest-events-controller.php
rename to includes/wpem-rest-events-controller.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
similarity index 100%
rename from includes/rest-api/wpem-rest-matchmaking-create-meetings.php
rename to includes/wpem-rest-matchmaking-create-meetings.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
similarity index 100%
rename from includes/rest-api/wpem-rest-matchmaking-filter-users.php
rename to includes/wpem-rest-matchmaking-filter-users.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-get-texonomy.php b/includes/wpem-rest-matchmaking-get-texonomy.php
similarity index 100%
rename from includes/rest-api/wpem-rest-matchmaking-get-texonomy.php
rename to includes/wpem-rest-matchmaking-get-texonomy.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
similarity index 100%
rename from includes/rest-api/wpem-rest-matchmaking-profile.php
rename to includes/wpem-rest-matchmaking-profile.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
similarity index 100%
rename from includes/rest-api/wpem-rest-matchmaking-user-messages.php
rename to includes/wpem-rest-matchmaking-user-messages.php
diff --git a/includes/rest-api/wpem-rest-matchmaking-user-registred-events.php b/includes/wpem-rest-matchmaking-user-registred-events.php
similarity index 100%
rename from includes/rest-api/wpem-rest-matchmaking-user-registred-events.php
rename to includes/wpem-rest-matchmaking-user-registred-events.php
diff --git a/includes/rest-api/wpem-rest-organizers-controller.php b/includes/wpem-rest-organizers-controller.php
similarity index 100%
rename from includes/rest-api/wpem-rest-organizers-controller.php
rename to includes/wpem-rest-organizers-controller.php
diff --git a/includes/rest-api/wpem-rest-posts-conroller.php b/includes/wpem-rest-posts-conroller.php
similarity index 100%
rename from includes/rest-api/wpem-rest-posts-conroller.php
rename to includes/wpem-rest-posts-conroller.php
diff --git a/includes/rest-api/wpem-rest-venues-controller.php b/includes/wpem-rest-venues-controller.php
similarity index 100%
rename from includes/rest-api/wpem-rest-venues-controller.php
rename to includes/wpem-rest-venues-controller.php
diff --git a/readme.txt b/readme.txt
index 936617f..5d55b8f 100755
--- a/readme.txt
+++ b/readme.txt
@@ -1,4 +1,4 @@
-=== WPEM - REST API ===
+=== WP Event Manager - REST API ===
Contributors: wpeventmanager,ashokdudhat,krinay
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=55FRYATTFLA5N
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 3d14a69..0b1c000 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -1,6 +1,6 @@
Date: Fri, 30 May 2025 12:15:14 +0530
Subject: [PATCH 036/171] #167 Set token validation to all the match making
apis.
---
includes/wpem-rest-authentication.php | 43 +++++++++++++++++++
.../wpem-rest-matchmaking-create-meetings.php | 5 ++-
.../wpem-rest-matchmaking-filter-users.php | 5 ++-
.../wpem-rest-matchmaking-get-texonomy.php | 3 +-
includes/wpem-rest-matchmaking-profile.php | 7 +--
.../wpem-rest-matchmaking-user-messages.php | 5 ++-
...rest-matchmaking-user-registred-events.php | 3 +-
7 files changed, 60 insertions(+), 11 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index e3ba472..6649c32 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -755,6 +755,49 @@ public function wpem_generate_jwt_token($user_id) {
// Return standard JWT format
return $header . '.' . $payload . '.' . $signature;
}
+
+ /**
+ * This function will used to check authentication while use the match making apis
+ * @since 1.1.0
+ */
+ public function check_authentication( $request ) {
+ $auth_header = $this->get_authorization_header();
+
+ if ( preg_match( '/Bearer\s(\S+)/', $auth_header, $matches ) ) {
+ $token = $matches[1];
+
+ return $this->validate_jwt_token($token);
+ }
+
+ return new WP_Error( 'rest_forbidden', __( 'Missing or invalid authorization token.', 'textdomain' ), array( 'status' => 401 ) );
+ }
+ /**
+ * This function will used to check validation of jwt token
+ * @since 1.1.0
+ */
+ private function validate_jwt_token($token) {
+ $parts = explode('.', $token);
+ if (count($parts) !== 3) {
+ return new WP_Error( 'rest_forbidden', __( 'Malformed token.', 'textdomain' ), array( 'status' => 401 ) );
+ }
+
+ list($header_b64, $payload_b64, $signature_b64) = $parts;
+
+ $expected_signature = wpem_base64url_encode(
+ hash_hmac('sha256', "$header_b64.$payload_b64", JWT_SECRET_KEY, true)
+ );
+
+ if (!hash_equals($expected_signature, $signature_b64)) {
+ return new WP_Error( 'rest_forbidden', __( 'Invalid token signature.', 'textdomain' ), array( 'status' => 401 ) );
+ }
+
+ $payload = json_decode(base64_decode(strtr($payload_b64, '-_', '+/')), true);
+ if (!isset($payload['user']['id'])) {
+ return new WP_Error( 'rest_forbidden', __( 'Invalid token payload.', 'textdomain' ), array( 'status' => 401 ) );
+ }
+
+ return true;
+ }
}
new WPEM_REST_Authentication();
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 492de4b..6efa42a 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -10,11 +10,12 @@ public function __construct() {
}
public function register_routes() {
+ $auth_controller = new WPEM_REST_Authentication();
// Create Meeting
register_rest_route($this->namespace, '/' . $this->rest_base, [
'methods' => WP_REST_Server::CREATABLE,
'callback' => [$this, 'create_meeting'],
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => [
'user_id' => ['required' => true, 'type' => 'integer'],
'event_id' => ['required' => true, 'type' => 'integer'],
@@ -30,7 +31,7 @@ public function register_routes() {
register_rest_route($this->namespace, '/get-meetings', [
'methods' => WP_REST_Server::CREATABLE,
'callback' => [$this, 'get_user_meetings'],
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
]);
}
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 49daa3b..5cac35f 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -9,11 +9,12 @@ public function __construct() {
}
public function register_routes() {
+ $auth_controller = new WPEM_REST_Authentication();
// General filter
register_rest_route($this->namespace, '/' . $this->rest_base, array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'handle_filter_users'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'profession' => array('required' => false, 'type' => 'string'),
'company_name' => array('required' => false, 'type' => 'string'),
@@ -29,7 +30,7 @@ public function register_routes() {
register_rest_route($this->namespace, '/your-matches', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'handle_your_matches'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'user_id' => array('required' => false, 'type' => 'integer'),
),
diff --git a/includes/wpem-rest-matchmaking-get-texonomy.php b/includes/wpem-rest-matchmaking-get-texonomy.php
index cfd220d..056e407 100644
--- a/includes/wpem-rest-matchmaking-get-texonomy.php
+++ b/includes/wpem-rest-matchmaking-get-texonomy.php
@@ -9,13 +9,14 @@ public function __construct() {
}
public function register_routes() {
+ $auth_controller = new WPEM_REST_Authentication();
register_rest_route(
$this->namespace,
'/' . $this->rest_base,
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'get_taxonomy_terms'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'taxonomy' => array(
'required' => true,
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 02912e8..86bde09 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -9,13 +9,14 @@ public function __construct() {
}
public function register_routes() {
+ $auth_controller = new WPEM_REST_Authentication();
register_rest_route(
$this->namespace,
'/attendee-profile',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'get_attendee_profile'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'attendeeId' => array(
'required' => false,
@@ -31,7 +32,7 @@ public function register_routes() {
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_attendee_profile'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'user_id' => array(
'required' => true,
@@ -47,7 +48,7 @@ public function register_routes() {
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array($this, 'upload_user_file'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'user_id' => array(
'required' => true,
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index f792b54..420b186 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -11,10 +11,11 @@ public function __construct() {
}
public function register_routes() {
+ $auth_controller = new WPEM_REST_Authentication();
register_rest_route($this->namespace, '/' . $this->rest_base, array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array($this, 'handle_send_message'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'senderId' => array('required' => true, 'type' => 'integer'),
'receiverId' => array('required' => true, 'type' => 'integer'),
@@ -26,7 +27,7 @@ public function register_routes() {
register_rest_route($this->namespace, '/get-messages', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'handle_get_messages'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'senderId' => array('required' => true, 'type' => 'integer'),
'receiverId' => array('required' => true, 'type' => 'integer'),
diff --git a/includes/wpem-rest-matchmaking-user-registred-events.php b/includes/wpem-rest-matchmaking-user-registred-events.php
index 7cbf56c..170ceab 100644
--- a/includes/wpem-rest-matchmaking-user-registred-events.php
+++ b/includes/wpem-rest-matchmaking-user-registred-events.php
@@ -9,13 +9,14 @@ public function __construct() {
}
public function register_routes() {
+ $auth_controller = new WPEM_REST_Authentication();
register_rest_route(
$this->namespace,
'/' . $this->rest_base,
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'get_user_registered_events'),
- 'permission_callback' => '__return_true',
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
'user_id' => array(
'required' => true,
From 19c28c8b8598063941673e2d30a8f09d7964541a Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 30 May 2025 12:19:44 +0530
Subject: [PATCH 037/171] #165 Update organization logo
---
includes/wpem-rest-matchmaking-profile.php | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 86bde09..1d63d64 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -168,6 +168,28 @@ public function update_attendee_profile($request) {
}
}
+ // Handle organization_logo file upload if present in $_FILES
+ if (!empty($_FILES['organization_logo']) && $_FILES['organization_logo']['error'] === UPLOAD_ERR_OK) {
+ require_once ABSPATH . 'wp-admin/includes/file.php';
+ $upload_overrides = array('test_form' => false);
+
+ $movefile = wp_handle_upload($_FILES['organization_logo'], $upload_overrides);
+
+ if (isset($movefile['url'])) {
+ $organization_logo_url = esc_url_raw($movefile['url']);
+ $custom_data['organization_logo'] = $organization_logo_url;
+ update_user_meta($user_id, '_organization_logo', $organization_logo_url); // optional
+ } else {
+ return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Organization logo upload failed.'], 500);
+ }
+ } else {
+ if ($request->get_param('organization_logo') !== null) {
+ $organization_logo_url = esc_url_raw($request->get_param('organization_logo'));
+ $custom_data['organization_logo'] = $organization_logo_url;
+ update_user_meta($user_id, '_organization_logo', $organization_logo_url); // optional
+ }
+ }
+
if (!empty($custom_data)) {
$updated = $wpdb->update($table, $custom_data, ['user_id' => $user_id]);
if ($updated === false) {
From 59d850acf9e74ab01ae6af4eccf4fd8b7d4672fc Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 2 Jun 2025 12:06:01 +0530
Subject: [PATCH 038/171] #160 Add event banner in response
---
includes/wpem-rest-matchmaking-user-registred-events.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-matchmaking-user-registred-events.php b/includes/wpem-rest-matchmaking-user-registred-events.php
index 170ceab..c615f58 100644
--- a/includes/wpem-rest-matchmaking-user-registred-events.php
+++ b/includes/wpem-rest-matchmaking-user-registred-events.php
@@ -74,6 +74,7 @@ public function get_user_registered_events($request) {
'start_date' => get_post_meta($event_id, '_event_start_date', true),
'end_date' => get_post_meta($event_id, '_event_end_date', true),
'location' => get_post_meta($event_id, '_event_location', true),
+ 'banner' => get_post_meta($event_id, '_event_banner', true),
);
}
}
From 0008f6c0f57d88ccdd01b2e392438e81e37e8062 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 3 Jun 2025 15:47:20 +0530
Subject: [PATCH 039/171] #168 Changes in Your-Matches and filter API
---
.../wpem-rest-matchmaking-filter-users.php | 37 ++++++++++++-------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 5cac35f..b69f800 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -99,15 +99,19 @@ public function handle_your_matches($request) {
// Reuse the filter handler
$response = $this->handle_filter_users($filter_request);
- // Exclude the user from their own matches
if ($response instanceof WP_REST_Response) {
- $data = $response->get_data();
- $data['data'] = array_values(array_filter($data['data'], function ($item) use ($user_id) {
- return $item['user_id'] != $user_id;
- }));
- $response->set_data($data);
- }
-
+ $data = $response->get_data();
+
+ $filtered = array_filter($data['data'], function ($item) use ($user_id) {
+ return $item['user_id'] != $user_id;
+ });
+ foreach ($filtered as &$row) {
+ $row['first_name'] = get_user_meta($row['user_id'], 'first_name', true);
+ $row['last_name'] = get_user_meta($row['user_id'], 'last_name', true);
+ }
+ $data['data'] = array_values($filtered);
+ $response->set_data($data);
+ }
return $response;
}
@@ -191,12 +195,17 @@ public function handle_filter_users($request) {
$prepared_sql = $wpdb->prepare($sql, $query_params);
$results = $wpdb->get_results($prepared_sql, ARRAY_A);
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Users retrieved successfully.',
- 'data' => $results
- ], 200);
+ foreach ($results as &$row) {
+ $user_id = $row['user_id'];
+ $row['first_name'] = get_user_meta($user_id, 'first_name', true);
+ $row['last_name'] = get_user_meta($user_id, 'last_name', true);
+ }
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Users retrieved successfully.',
+ 'data' => $results
+ ], 200);
}
}
From 986542954a06baf3eec40c8c099e9699771c14a9 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 3 Jun 2025 18:02:51 +0530
Subject: [PATCH 040/171] #168 Changes in Your-Matches and filter API
---
.../wpem-rest-matchmaking-filter-users.php | 234 ++++++++++++------
1 file changed, 153 insertions(+), 81 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index b69f800..2b15d23 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -23,6 +23,9 @@ public function register_routes() {
'experience' => array('required' => false),
'skills' => array('required' => false, 'type' => 'array'),
'interests' => array('required' => false, 'type' => 'array'),
+ 'event_id' => array('required' => false, 'type' => 'integer'),
+ 'user_id' => array('required' => true, 'type' => 'integer'),
+
),
));
@@ -32,7 +35,7 @@ public function register_routes() {
'callback' => array($this, 'handle_your_matches'),
'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
- 'user_id' => array('required' => false, 'type' => 'integer'),
+ 'user_id' => array('required' => true, 'type' => 'integer'),
),
));
}
@@ -50,15 +53,12 @@ public function handle_your_matches($request) {
}
$user_id = intval($request->get_param('user_id'));
- if (!$user_id) {
- $user_id = get_current_user_id();
- }
-
+
if (!$user_id) {
return new WP_REST_Response([
'code' => 401,
'status' => 'Unauthorized',
- 'message' => 'User not logged in or user_id not provided'
+ 'message' => 'User Id not found'
], 401);
}
@@ -99,114 +99,186 @@ public function handle_your_matches($request) {
// Reuse the filter handler
$response = $this->handle_filter_users($filter_request);
+ // Exclude the user from their own matches
if ($response instanceof WP_REST_Response) {
$data = $response->get_data();
+ // Exclude self
$filtered = array_filter($data['data'], function ($item) use ($user_id) {
return $item['user_id'] != $user_id;
});
+
+ // Add first_name and last_name
foreach ($filtered as &$row) {
$row['first_name'] = get_user_meta($row['user_id'], 'first_name', true);
$row['last_name'] = get_user_meta($row['user_id'], 'last_name', true);
}
+
$data['data'] = array_values($filtered);
$response->set_data($data);
}
+
return $response;
}
- public function handle_filter_users($request) {
- global $wpdb;
-
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
-
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $where_clauses = [];
- $query_params = [];
-
- if ($profession = sanitize_text_field($request->get_param('profession'))) {
- $where_clauses[] = "profession = %s";
- $query_params[] = $profession;
- }
-
- $experience = $request->get_param('experience');
- if (is_array($experience) && isset($experience['min'], $experience['max'])) {
- $where_clauses[] = "experience BETWEEN %d AND %d";
- $query_params[] = (int)$experience['min'];
- $query_params[] = (int)$experience['max'];
- } elseif (is_numeric($experience)) {
- $where_clauses[] = "experience = %d";
- $query_params[] = (int)$experience;
- }
-
- if ($company = sanitize_text_field($request->get_param('company_name'))) {
- $where_clauses[] = "company_name = %s";
- $query_params[] = $company;
- }
+ public function handle_filter_users($request) {
+ global $wpdb;
- $countries = $request->get_param('country');
- if (is_array($countries)) {
- $placeholders = implode(',', array_fill(0, count($countries), '%s'));
- $where_clauses[] = "country IN ($placeholders)";
- $query_params = array_merge($query_params, array_map('sanitize_text_field', $countries));
- } elseif (!empty($countries)) {
- $country = sanitize_text_field($countries);
- $where_clauses[] = "country = %s";
- $query_params[] = $country;
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
- if ($city = sanitize_text_field($request->get_param('city'))) {
- $where_clauses[] = "city = %s";
- $query_params[] = $city;
- }
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $where_clauses = [];
+ $query_params = [];
+
+ $user_ids = [];
+
+ $event_id = $request->get_param('event_id');
+ if (!empty($event_id)) {
+ $current_user_id = $request->get_param('user_id');
+ if (!$current_user_id) {
+ return new WP_REST_Response([
+ 'code' => 401,
+ 'status' => 'Unauthorized',
+ 'message' => 'User not logged in.',
+ 'data' => []
+ ], 401);
+ }
- $skills = $request->get_param('skills');
- if (is_array($skills) && !empty($skills)) {
- foreach ($skills as $skill) {
- $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
- $where_clauses[] = "skills LIKE %s";
- $query_params[] = $like;
- }
- }
+ // Step 1: Check if current user is registered for the given event
+ $registration_query = new WP_Query([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => [
+ [
+ 'key' => '_attendee_user_id',
+ 'value' => $current_user_id,
+ ],
+ [
+ 'key' => '_event_id',
+ 'value' => $event_id,
+ ],
+ ],
+ ]);
+
+ if (!$registration_query->have_posts()) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Forbidden',
+ 'message' => 'You are not registered for this event.',
+ 'data' => []
+ ], 403);
+ }
- $interests = $request->get_param('interests');
- if (is_array($interests) && !empty($interests)) {
- foreach ($interests as $interest) {
- $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
- $where_clauses[] = "interests LIKE %s";
- $query_params[] = $like;
- }
- }
+ // Step 2: Fetch all other attendees for the same event
+ $attendee_query = new WP_Query([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => [
+ [
+ 'key' => '_event_id',
+ 'value' => $event_id,
+ ],
+ ],
+ ]);
+ foreach ($attendee_query->posts as $post_id) {
+ $uid = get_post_meta($post_id, '_attendee_user_id', true);
+ if ($uid && $uid != $current_user_id && !in_array($uid, $user_ids)) {
+ $user_ids[] = (int)$uid;
+ }
+ }
+ if (empty($user_ids)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No attendees found for this event.',
+ 'data' => []
+ ], 200);
+ }
- if (get_option('participant_activation') === 'manual') {
- $where_clauses[] = "approve_profile_status = '1'";
- }
+ // Restrict SQL to only these user_ids
+ $placeholders = implode(',', array_fill(0, count($user_ids), '%d'));
+ $where_clauses[] = "user_id IN ($placeholders)";
+ $query_params = array_merge($query_params, $user_ids);
+ }
+ if ($profession = sanitize_text_field($request->get_param('profession'))) {
+ $where_clauses[] = "profession = %s";
+ $query_params[] = $profession;
+ }
+ $experience = $request->get_param('experience');
+ if (is_array($experience) && isset($experience['min'], $experience['max'])) {
+ $where_clauses[] = "experience BETWEEN %d AND %d";
+ $query_params[] = (int)$experience['min'];
+ $query_params[] = (int)$experience['max'];
+ } elseif (is_numeric($experience)) {
+ $where_clauses[] = "experience = %d";
+ $query_params[] = (int)$experience;
+ }
+ if ($company = sanitize_text_field($request->get_param('company_name'))) {
+ $where_clauses[] = "company_name = %s";
+ $query_params[] = $company;
+ }
+ $countries = $request->get_param('country');
+ if (is_array($countries)) {
+ $placeholders = implode(',', array_fill(0, count($countries), '%s'));
+ $where_clauses[] = "country IN ($placeholders)";
+ $query_params = array_merge($query_params, array_map('sanitize_text_field', $countries));
+ } elseif (!empty($countries)) {
+ $country = sanitize_text_field($countries);
+ $where_clauses[] = "country = %s";
+ $query_params[] = $country;
+ }
+ if ($city = sanitize_text_field($request->get_param('city'))) {
+ $where_clauses[] = "city = %s";
+ $query_params[] = $city;
+ }
+ $skills = $request->get_param('skills');
+ if (is_array($skills) && !empty($skills)) {
+ foreach ($skills as $skill) {
+ $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
+ $where_clauses[] = "skills LIKE %s";
+ $query_params[] = $like;
+ }
+ }
+ $interests = $request->get_param('interests');
+ if (is_array($interests) && !empty($interests)) {
+ foreach ($interests as $interest) {
+ $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
+ $where_clauses[] = "interests LIKE %s";
+ $query_params[] = $like;
+ }
+ }
- $where_sql = $where_clauses ? 'WHERE ' . implode(' AND ', $where_clauses) : '';
- $sql = "SELECT * FROM $table $where_sql";
+ if (get_option('participant_activation') === 'manual') {
+ $where_clauses[] = "approve_profile_status = '1'";
+ }
- $prepared_sql = $wpdb->prepare($sql, $query_params);
- $results = $wpdb->get_results($prepared_sql, ARRAY_A);
+ $where_sql = $where_clauses ? 'WHERE ' . implode(' AND ', $where_clauses) : '';
+ $sql = "SELECT * FROM $table $where_sql";
+ $prepared_sql = $wpdb->prepare($sql, $query_params);
+ $results = $wpdb->get_results($prepared_sql, ARRAY_A);
- foreach ($results as &$row) {
+ foreach ($results as &$row) {
$user_id = $row['user_id'];
$row['first_name'] = get_user_meta($user_id, 'first_name', true);
$row['last_name'] = get_user_meta($user_id, 'last_name', true);
}
+
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
'message' => 'Users retrieved successfully.',
'data' => $results
], 200);
- }
+ }
+
}
-
new WPEM_REST_Filter_Users_Controller();
From f0ff169aac1d3e8456360cfc97a9e8e1baf8dea2 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 3 Jun 2025 18:43:30 +0530
Subject: [PATCH 041/171] #168 Solve error of db
---
includes/wpem-rest-matchmaking-create-meetings.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 6efa42a..f53c866 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -318,8 +318,8 @@ public function get_user_meetings(WP_REST_Request $request) {
$meeting_data[] = [
'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
- 'start_time' => date_i18n('h:i A', strtotime($meeting['start_time'])),
- 'end_time' => date_i18n('h:i A', strtotime($meeting['end_time'])),
+ 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
+ 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
'message' => $meeting['message'] ?? '',
'host' => $get_user_info($user_id),
'participants' => $participants_info,
From eb9a2c3d9ffb8ce1f2f0f7a65da9c4a55f8f6503 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 3 Jun 2025 18:51:01 +0530
Subject: [PATCH 042/171] #168 Add match making user data to login response
---
includes/wpem-rest-authentication.php | 33 ++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index 6649c32..f3c3be6 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -701,7 +701,38 @@ public function perform_user_authentication($request){
'enable_matchmaking' => $enable_matchmaking,
)
);
-
+ if ($is_matchmaking && $enable_matchmaking ) {
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $matchmaking_data = $wpdb->get_row(
+ $wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id),
+ ARRAY_A
+ );
+
+ if ($matchmaking_data) {
+ $data['user']['matchmaking_details'] = array(
+ 'attendeeId' => $matchmaking_data['user_id'],
+ 'firstName' => get_user_meta($user_id, 'first_name', true),
+ 'lastName' => get_user_meta($user_id, 'last_name', true),
+ 'email' => $user->user_email,
+ 'profilePhoto' => $matchmaking_data['profile_photo'] ?? '',
+ 'profession' => $matchmaking_data['profession'] ?? '',
+ 'experience' => $matchmaking_data['experience'] ?? '',
+ 'companyName' => $matchmaking_data['company_name'] ?? '',
+ 'country' => $matchmaking_data['country'] ?? '',
+ 'city' => $matchmaking_data['city'] ?? '',
+ 'about' => $matchmaking_data['about'] ?? '',
+ 'skills' => !empty($matchmaking_data['skills']) ? maybe_unserialize($matchmaking_data['skills']) : [],
+ 'interests' => !empty($matchmaking_data['interests']) ? maybe_unserialize($matchmaking_data['interests']) : [],
+ 'organizationName' => $matchmaking_data['organization_name'] ?? '',
+ 'organizationLogo' => $matchmaking_data['organization_logo'] ?? '',
+ 'organizationCity' => $matchmaking_data['organization_city'] ?? '',
+ 'organizationCountry' => $matchmaking_data['organization_country'] ?? '',
+ 'organizationDescription' => $matchmaking_data['organization_description'] ?? '',
+ 'messageNotification' => $matchmaking_data['message_notification'] ?? '',
+ 'approveProfileStatus' => $matchmaking_data['approve_profile_status'] ?? '',
+ );
+ }
+ }
$key_data = $wpdb->get_row(
$wpdb->prepare(
"
From 68a5cde2f690a84a0208269d0555b64365c1d6ad Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 3 Jun 2025 19:08:32 +0530
Subject: [PATCH 043/171] #168 added search parameter in filter
---
.../wpem-rest-matchmaking-filter-users.php | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 2b15d23..c9987d4 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -25,6 +25,7 @@ public function register_routes() {
'interests' => array('required' => false, 'type' => 'array'),
'event_id' => array('required' => false, 'type' => 'integer'),
'user_id' => array('required' => true, 'type' => 'integer'),
+ 'search' => array('required' => false, 'type' => 'string'),
),
));
@@ -96,6 +97,39 @@ public function handle_your_matches($request) {
$filter_request->set_param('interests', $interests);
}
+ $search = sanitize_text_field($request->get_param('search'));
+ if (!empty($search)) {
+ $search_like = '%' . $wpdb->esc_like($search) . '%';
+
+ $search_conditions = [
+ "about LIKE %s",
+ "city LIKE %s",
+ "country LIKE %s",
+ "profession LIKE %s",
+ "skills LIKE %s",
+ "interests LIKE %s",
+ "company_name LIKE %s"
+ ];
+
+ // First name / last name from wp_usermeta
+ $matching_user_ids = $wpdb->get_col($wpdb->prepare("
+ SELECT DISTINCT user_id
+ FROM {$wpdb->usermeta}
+ WHERE (meta_key = 'first_name' OR meta_key = 'last_name')
+ AND meta_value LIKE %s
+ ", $search_like));
+
+ if (!empty($matching_user_ids)) {
+ $placeholders = implode(',', array_fill(0, count($matching_user_ids), '%d'));
+ $search_conditions[] = "user_id IN ($placeholders)";
+ $query_params = array_merge($query_params, array_fill(0, count($search_conditions) - 1, $search_like), $matching_user_ids);
+ } else {
+ $query_params = array_merge($query_params, array_fill(0, count($search_conditions), $search_like));
+ }
+
+ $where_clauses[] = '(' . implode(' OR ', $search_conditions) . ')';
+ }
+
// Reuse the filter handler
$response = $this->handle_filter_users($filter_request);
From 467af350c803792784103f60fab2573f6b29d9d8 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 4 Jun 2025 11:49:18 +0530
Subject: [PATCH 044/171] #169 Pagination Needed in Your matches and filter
user
---
.../wpem-rest-matchmaking-filter-users.php | 347 ++++++++++--------
1 file changed, 195 insertions(+), 152 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index c9987d4..c063dad 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -23,9 +23,11 @@ public function register_routes() {
'experience' => array('required' => false),
'skills' => array('required' => false, 'type' => 'array'),
'interests' => array('required' => false, 'type' => 'array'),
- 'event_id' => array('required' => false, 'type' => 'integer'),
- 'user_id' => array('required' => true, 'type' => 'integer'),
- 'search' => array('required' => false, 'type' => 'string'),
+ 'event_id' => array('required' => false, 'type' => 'integer'),
+ 'user_id' => array('required' => true, 'type' => 'integer'),
+ 'search' => array('required' => false, 'type' => 'string'),
+ 'per_page' => array('required' => false, 'type' => 'integer', 'default' => 5),
+ 'page' => array('required' => false, 'type' => 'integer', 'default' => 1),
),
));
@@ -155,164 +157,205 @@ public function handle_your_matches($request) {
return $response;
}
- public function handle_filter_users($request) {
- global $wpdb;
+ public function handle_filter_users($request) {
+ global $wpdb;
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $where_clauses = [];
- $query_params = [];
-
- $user_ids = [];
-
- $event_id = $request->get_param('event_id');
- if (!empty($event_id)) {
- $current_user_id = $request->get_param('user_id');
- if (!$current_user_id) {
- return new WP_REST_Response([
- 'code' => 401,
- 'status' => 'Unauthorized',
- 'message' => 'User not logged in.',
- 'data' => []
- ], 401);
- }
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $where_clauses = [];
+ $query_params = [];
+ $user_ids = [];
+
+ $event_id = $request->get_param('event_id');
+ $current_user_id = $request->get_param('user_id');
+
+ if (!empty($event_id)) {
+ if (!$current_user_id) {
+ return new WP_REST_Response([
+ 'code' => 401,
+ 'status' => 'Unauthorized',
+ 'message' => 'User not logged in.',
+ 'data' => []
+ ], 401);
+ }
+
+ $registration_query = new WP_Query([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => [
+ ['key' => '_attendee_user_id', 'value' => $current_user_id],
+ ['key' => '_event_id', 'value' => $event_id],
+ ],
+ ]);
+
+ if (!$registration_query->have_posts()) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Forbidden',
+ 'message' => 'You are not registered for this event.',
+ 'data' => []
+ ], 403);
+ }
+
+ $attendee_query = new WP_Query([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => [['key' => '_event_id', 'value' => $event_id]],
+ ]);
+
+ foreach ($attendee_query->posts as $post_id) {
+ $uid = get_post_meta($post_id, '_attendee_user_id', true);
+ if ($uid && $uid != $current_user_id && !in_array($uid, $user_ids)) {
+ $user_ids[] = (int)$uid;
+ }
+ }
+
+ if (empty($user_ids)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No attendees found for this event.',
+ 'data' => []
+ ], 200);
+ }
+
+ $placeholders = implode(',', array_fill(0, count($user_ids), '%d'));
+ $where_clauses[] = "user_id IN ($placeholders)";
+ $query_params = array_merge($query_params, $user_ids);
+ }
- // Step 1: Check if current user is registered for the given event
- $registration_query = new WP_Query([
- 'post_type' => 'event_registration',
- 'posts_per_page' => -1,
- 'fields' => 'ids',
- 'meta_query' => [
- [
- 'key' => '_attendee_user_id',
- 'value' => $current_user_id,
- ],
- [
- 'key' => '_event_id',
- 'value' => $event_id,
- ],
- ],
- ]);
-
- if (!$registration_query->have_posts()) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Forbidden',
- 'message' => 'You are not registered for this event.',
- 'data' => []
- ], 403);
- }
+ if ($profession = sanitize_text_field($request->get_param('profession'))) {
+ $where_clauses[] = "profession = %s";
+ $query_params[] = $profession;
+ }
- // Step 2: Fetch all other attendees for the same event
- $attendee_query = new WP_Query([
- 'post_type' => 'event_registration',
- 'posts_per_page' => -1,
- 'fields' => 'ids',
- 'meta_query' => [
- [
- 'key' => '_event_id',
- 'value' => $event_id,
- ],
- ],
- ]);
- foreach ($attendee_query->posts as $post_id) {
- $uid = get_post_meta($post_id, '_attendee_user_id', true);
- if ($uid && $uid != $current_user_id && !in_array($uid, $user_ids)) {
- $user_ids[] = (int)$uid;
- }
- }
- if (empty($user_ids)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No attendees found for this event.',
- 'data' => []
- ], 200);
- }
+ $experience = $request->get_param('experience');
+ if (is_array($experience) && isset($experience['min'], $experience['max'])) {
+ $where_clauses[] = "experience BETWEEN %d AND %d";
+ $query_params[] = (int)$experience['min'];
+ $query_params[] = (int)$experience['max'];
+ } elseif (is_numeric($experience)) {
+ $where_clauses[] = "experience = %d";
+ $query_params[] = (int)$experience;
+ }
- // Restrict SQL to only these user_ids
- $placeholders = implode(',', array_fill(0, count($user_ids), '%d'));
- $where_clauses[] = "user_id IN ($placeholders)";
- $query_params = array_merge($query_params, $user_ids);
- }
- if ($profession = sanitize_text_field($request->get_param('profession'))) {
- $where_clauses[] = "profession = %s";
- $query_params[] = $profession;
- }
- $experience = $request->get_param('experience');
- if (is_array($experience) && isset($experience['min'], $experience['max'])) {
- $where_clauses[] = "experience BETWEEN %d AND %d";
- $query_params[] = (int)$experience['min'];
- $query_params[] = (int)$experience['max'];
- } elseif (is_numeric($experience)) {
- $where_clauses[] = "experience = %d";
- $query_params[] = (int)$experience;
- }
- if ($company = sanitize_text_field($request->get_param('company_name'))) {
- $where_clauses[] = "company_name = %s";
- $query_params[] = $company;
- }
- $countries = $request->get_param('country');
- if (is_array($countries)) {
- $placeholders = implode(',', array_fill(0, count($countries), '%s'));
- $where_clauses[] = "country IN ($placeholders)";
- $query_params = array_merge($query_params, array_map('sanitize_text_field', $countries));
- } elseif (!empty($countries)) {
- $country = sanitize_text_field($countries);
- $where_clauses[] = "country = %s";
- $query_params[] = $country;
- }
- if ($city = sanitize_text_field($request->get_param('city'))) {
- $where_clauses[] = "city = %s";
- $query_params[] = $city;
- }
- $skills = $request->get_param('skills');
- if (is_array($skills) && !empty($skills)) {
- foreach ($skills as $skill) {
- $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
- $where_clauses[] = "skills LIKE %s";
- $query_params[] = $like;
- }
- }
- $interests = $request->get_param('interests');
- if (is_array($interests) && !empty($interests)) {
- foreach ($interests as $interest) {
- $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
- $where_clauses[] = "interests LIKE %s";
- $query_params[] = $like;
- }
- }
+ if ($company = sanitize_text_field($request->get_param('company_name'))) {
+ $where_clauses[] = "company_name = %s";
+ $query_params[] = $company;
+ }
- if (get_option('participant_activation') === 'manual') {
- $where_clauses[] = "approve_profile_status = '1'";
- }
+ $countries = $request->get_param('country');
+ if (is_array($countries)) {
+ $placeholders = implode(',', array_fill(0, count($countries), '%s'));
+ $where_clauses[] = "country IN ($placeholders)";
+ $query_params = array_merge($query_params, array_map('sanitize_text_field', $countries));
+ } elseif (!empty($countries)) {
+ $country = sanitize_text_field($countries);
+ $where_clauses[] = "country = %s";
+ $query_params[] = $country;
+ }
- $where_sql = $where_clauses ? 'WHERE ' . implode(' AND ', $where_clauses) : '';
- $sql = "SELECT * FROM $table $where_sql";
- $prepared_sql = $wpdb->prepare($sql, $query_params);
- $results = $wpdb->get_results($prepared_sql, ARRAY_A);
+ if ($city = sanitize_text_field($request->get_param('city'))) {
+ $where_clauses[] = "city = %s";
+ $query_params[] = $city;
+ }
- foreach ($results as &$row) {
- $user_id = $row['user_id'];
- $row['first_name'] = get_user_meta($user_id, 'first_name', true);
- $row['last_name'] = get_user_meta($user_id, 'last_name', true);
- }
+ $skills = $request->get_param('skills');
+ if (is_array($skills) && !empty($skills)) {
+ foreach ($skills as $skill) {
+ $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
+ $where_clauses[] = "skills LIKE %s";
+ $query_params[] = $like;
+ }
+ }
+
+ $interests = $request->get_param('interests');
+ if (is_array($interests) && !empty($interests)) {
+ foreach ($interests as $interest) {
+ $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
+ $where_clauses[] = "interests LIKE %s";
+ $query_params[] = $like;
+ }
+ }
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Users retrieved successfully.',
- 'data' => $results
- ], 200);
- }
+ $search = sanitize_text_field($request->get_param('search'));
+ if (!empty($search)) {
+ $search_like = '%' . $wpdb->esc_like($search) . '%';
+
+ $search_conditions = [
+ "about LIKE %s",
+ "city LIKE %s",
+ "country LIKE %s",
+ "profession LIKE %s",
+ "skills LIKE %s",
+ "interests LIKE %s",
+ "company_name LIKE %s"
+ ];
+
+ $matching_user_ids = $wpdb->get_col($wpdb->prepare("
+ SELECT DISTINCT user_id FROM {$wpdb->usermeta}
+ WHERE (meta_key = 'first_name' OR meta_key = 'last_name')
+ AND meta_value LIKE %s
+ ", $search_like));
+
+ if (!empty($matching_user_ids)) {
+ $placeholders = implode(',', array_fill(0, count($matching_user_ids), '%d'));
+ $search_conditions[] = "user_id IN ($placeholders)";
+ $query_params = array_merge($query_params, array_fill(0, count($search_conditions) - 1, $search_like), $matching_user_ids);
+ } else {
+ $query_params = array_merge($query_params, array_fill(0, count($search_conditions), $search_like));
+ }
+
+ $where_clauses[] = '(' . implode(' OR ', $search_conditions) . ')';
+ }
+
+ if (get_option('participant_activation') === 'manual') {
+ $where_clauses[] = "approve_profile_status = '1'";
+ }
+
+ $where_sql = $where_clauses ? 'WHERE ' . implode(' AND ', $where_clauses) : '';
+ $sql = "SELECT * FROM $table $where_sql";
+ $count_sql = "SELECT COUNT(*) FROM $table $where_sql";
+
+ $total = (int) $wpdb->get_var($wpdb->prepare($count_sql, $query_params));
+
+ $per_page = max(1, (int) $request->get_param('per_page'));
+ $page = max(1, (int) $request->get_param('page'));
+ $offset = ($page - 1) * $per_page;
+
+ $sql .= $wpdb->prepare(" LIMIT %d OFFSET %d", $per_page, $offset);
+ $query_params[] = $per_page;
+ $query_params[] = $offset;
+
+ $prepared_sql = $wpdb->prepare($sql, $query_params);
+ $results = $wpdb->get_results($prepared_sql, ARRAY_A);
+
+ foreach ($results as &$row) {
+ $user_id = $row['user_id'];
+ $row['first_name'] = get_user_meta($user_id, 'first_name', true);
+ $row['last_name'] = get_user_meta($user_id, 'last_name', true);
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Users retrieved successfully.',
+ 'data' => $results,
+ 'total' => $total,
+ 'page' => $page,
+ 'per_page' => $per_page,
+ ], 200);
+ }
}
new WPEM_REST_Filter_Users_Controller();
From cf01997c4b544b727f472695ad7a7be69abc3a86 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 4 Jun 2025 16:06:07 +0530
Subject: [PATCH 045/171] #129 Need to give selection of the events
---
admin/templates/html-keys-edit.php | 46 ++++++++++++++++++++++++++++++
assets/js/admin.js | 17 +++++++++++
assets/js/admin.min.js | 2 +-
3 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/admin/templates/html-keys-edit.php b/admin/templates/html-keys-edit.php
index c83b95e..a7880c2 100644
--- a/admin/templates/html-keys-edit.php
+++ b/admin/templates/html-keys-edit.php
@@ -140,6 +140,52 @@
value="1" >
+
+
+
+
+
+
+
+
+ />
+
+
+
+ />
+
+
+
+
+
+
+
+
+
+
+ 'event_listing',
+ 'post_status' => 'publish',
+ 'posts_per_page' => -1,
+ 'orderby' => 'title',
+ 'order' => 'ASC',
+ ) );
+ ?>
+
+
+ ID, $selected_events ), true ); ?>>
+ post_title ); ?>
+
+
+
+
+
diff --git a/assets/js/admin.js b/assets/js/admin.js
index 6280684..87e3158 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -4,6 +4,7 @@ var WPEMRestAPIAdmin = (function () {
jQuery("#update_api_key").on("click", WPEMRestAPIAdmin.actions.saveApiKey),
jQuery("select#key_user").chosen(),
jQuery("select#event_id").chosen(),
+ jQuery("#select_events").chosen();
jQuery("input#date_expires").datepicker({dateFormat: "yy-mm-dd",minDate: 0}),
jQuery("table#app-branding-color-dark").hide(),
jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click(function () {
@@ -24,6 +25,21 @@ var WPEMRestAPIAdmin = (function () {
}, 500));
},
});
+ // show events by radio button toggle
+ toggleEventsRow();
+ jQuery('input[name="event_show_by"]').change(function() {
+
+ toggleEventsRow();
+ });
+
+ function toggleEventsRow() {
+ if (jQuery('input[name="event_show_by"]:checked').val() === 'selected') {
+ jQuery('#select-events-row').show();
+ jQuery('#select_events').chosen('destroy').chosen();
+ } else {
+ jQuery('#select-events-row').hide();
+ }
+ }
},
actions: {
saveApiKey: function (e) {
@@ -44,6 +60,7 @@ var WPEMRestAPIAdmin = (function () {
event_id: jQuery("#event_id").val(),
date_expires: jQuery("#date_expires").val(),
restrict_check_in: jQuery('input[name="restrict_check_in"]').attr("checked") ? 0 : 1,
+
},
beforeSend: function (e) {},
success: function (e) {
diff --git a/assets/js/admin.min.js b/assets/js/admin.min.js
index df02410..b1e88e8 100644
--- a/assets/js/admin.min.js
+++ b/assets/js/admin.min.js
@@ -1 +1 @@
-var WPEMRestAPIAdmin={init:function(){var e;jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}})},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
")},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
+var WPEMRestAPIAdmin={init:function(){var e;function a(){"selected"===jQuery('input[name="event_show_by"]:checked').val()?(jQuery("#select-events-row").show(),jQuery("#select_events").chosen("destroy").chosen()):jQuery("#select-events-row").hide()}jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("#select_events").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}}),a(),jQuery('input[name="event_show_by"]').change((function(){a()}))},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
")},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
From bb5b510f2e93b37ae1bdb347374fd6e8462f19a4 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 4 Jun 2025 16:13:56 +0530
Subject: [PATCH 046/171] #168 change method of filter api
---
includes/wpem-rest-matchmaking-filter-users.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index c063dad..c171eb7 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -12,7 +12,7 @@ public function register_routes() {
$auth_controller = new WPEM_REST_Authentication();
// General filter
register_rest_route($this->namespace, '/' . $this->rest_base, array(
- 'methods' => WP_REST_Server::READABLE,
+ 'methods' => WP_REST_Server::CREATABLE,
'callback' => array($this, 'handle_filter_users'),
'permission_callback' => array($auth_controller, 'check_authentication'),
'args' => array(
From f58c53da65e7b2730aaad32ab48c5589a53f3089 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 4 Jun 2025 17:34:42 +0530
Subject: [PATCH 047/171] #129 Need to give selection of the events
---
admin/templates/html-keys-edit.php | 100 ++++++++++++++++-------------
admin/wpem-rest-api-admin.php | 23 +++++--
admin/wpem-rest-api-keys.php | 2 +-
assets/js/admin.js | 12 ++--
assets/js/admin.min.js | 2 +-
5 files changed, 82 insertions(+), 57 deletions(-)
diff --git a/admin/templates/html-keys-edit.php b/admin/templates/html-keys-edit.php
index a7880c2..231452b 100644
--- a/admin/templates/html-keys-edit.php
+++ b/admin/templates/html-keys-edit.php
@@ -103,6 +103,59 @@
+
+
+
+
+
+
+
+ />
+
+
+
+ />
+
+
+
+
+
+
+
+
+
+
+ 'event_listing',
+ 'post_status' => 'publish',
+ 'posts_per_page' => -1,
+ 'orderby' => 'title',
+ 'order' => 'ASC',
+ ));
+ ?>
+
+
+ ID, $selected_events), true); ?>>
+ post_title); ?>
+
+
+
+
+
+
@@ -141,52 +194,7 @@
value="1" >
-
-
-
-
-
-
-
- />
-
-
-
- />
-
-
-
-
-
-
-
-
-
-
- 'event_listing',
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'orderby' => 'title',
- 'order' => 'ASC',
- ) );
- ?>
-
-
- ID, $selected_events ), true ); ?>>
- post_title ); ?>
-
-
-
-
-
-
+
diff --git a/admin/wpem-rest-api-admin.php b/admin/wpem-rest-api-admin.php
index c1036d3..64973b5 100644
--- a/admin/wpem-rest-api-admin.php
+++ b/admin/wpem-rest-api-admin.php
@@ -111,6 +111,8 @@ public function update_api_key(){
$event_id = !empty( $_POST['event_id'] ) ? absint( $_POST['event_id'] ) : '' ;
$date_expires = !empty( $_POST['date_expires'] ) ? date( 'Y-m-d H:i:s', strtotime( str_replace( '-', '/', $_POST['date_expires'] ) ) ) : null ;
$restrict_check_in = isset( $_POST['restrict_check_in'] ) ? sanitize_text_field( $_POST['restrict_check_in'] ) : '';
+ $event_show_by = isset($_POST['event_show_by']) ? sanitize_text_field($_POST['event_show_by']) : 'loggedin';
+ $select_events = isset($_POST['select_events']) ? maybe_serialize(array_map('absint', $_POST['select_events'])) : maybe_serialize(array());
// Check if current user can edit other users.
if( $user_id && ! current_user_can( 'edit_user', $user_id ) ) {
@@ -121,11 +123,13 @@ public function update_api_key(){
if( 0 < $key_id ) {
$data = array(
- 'user_id' => $user_id,
- 'description' => $description,
- 'permissions' => $permissions,
- 'event_id' => $event_id,
- 'date_expires' => $date_expires,
+ 'user_id' => $user_id,
+ 'description' => $description,
+ 'permissions' => $permissions,
+ 'event_id' => $event_id,
+ 'date_expires' => $date_expires,
+ 'event_show_by' => $event_show_by,
+ 'selected_events' => $select_events,
);
$wpdb->update(
@@ -138,6 +142,8 @@ public function update_api_key(){
'%s',
'%d',
'%s',
+ '%s',
+ '%s',
),
array( '%d' )
);
@@ -146,6 +152,7 @@ public function update_api_key(){
$response['consumer_key'] = '';
$response['consumer_secret'] = '';
$response['message'] = __( 'API Key updated successfully.', 'wpem-rest-api' );
+ $response['selected_events'] = maybe_unserialize($select_events);
} else {
$app_key = wp_rand();
$consumer_key = 'ck_' . sha1(wp_rand());
@@ -162,6 +169,8 @@ public function update_api_key(){
'truncated_key' => substr($consumer_key, -7),
'date_created' => current_time( 'mysql' ) ,
'date_expires' => $date_expires,
+ 'event_show_by' => $event_show_by,
+ 'selected_events' => $select_events,
);
$wpdb->insert(
$wpdb->prefix . 'wpem_rest_api_keys',
@@ -177,6 +186,8 @@ public function update_api_key(){
'%s',
'%s',
'%s',
+ '%s',
+ '%s',
)
);
$key_id = $wpdb->insert_id;
@@ -186,6 +197,8 @@ public function update_api_key(){
$response['app_key'] = $app_key;
$response['message'] = __( 'API Key generated successfully. Make sure to copy your new keys now as the secret key will be hidden once you leave this page.', 'wpem-rest-api' );
$response['revoke_url'] = '' . __('I have Copied the Keys', 'wpem-rest-api') . ' ' . __('Revoke key', 'wpem-rest-api') . ' ';
+ $response['event_show_by'] = $event_show_by;
+ $response['selected_events'] = maybe_unserialize($select_events);
}
} catch ( Exception $e ) {
wp_send_json_error( array( 'message' => $e->getMessage() ) );
diff --git a/admin/wpem-rest-api-keys.php b/admin/wpem-rest-api-keys.php
index 2917116..68d2868 100644
--- a/admin/wpem-rest-api-keys.php
+++ b/admin/wpem-rest-api-keys.php
@@ -143,7 +143,7 @@ private static function get_key_data( $key_id ){
$key = $wpdb->get_row(
$wpdb->prepare(
- "SELECT key_id, user_id, event_id, description, permissions, truncated_key, last_access, date_expires
+ "SELECT key_id, user_id, event_id, description, permissions, truncated_key, last_access, event_show_by, selected_events, date_expires
FROM {$wpdb->prefix}wpem_rest_api_keys
WHERE key_id = %d",
$key_id
diff --git a/assets/js/admin.js b/assets/js/admin.js
index 87e3158..276958a 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -4,7 +4,7 @@ var WPEMRestAPIAdmin = (function () {
jQuery("#update_api_key").on("click", WPEMRestAPIAdmin.actions.saveApiKey),
jQuery("select#key_user").chosen(),
jQuery("select#event_id").chosen(),
- jQuery("#select_events").chosen();
+ jQuery("#select_events").chosen();
jQuery("input#date_expires").datepicker({dateFormat: "yy-mm-dd",minDate: 0}),
jQuery("table#app-branding-color-dark").hide(),
jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click(function () {
@@ -25,7 +25,8 @@ var WPEMRestAPIAdmin = (function () {
}, 500));
},
});
- // show events by radio button toggle
+
+ // show events by radio button toggle
toggleEventsRow();
jQuery('input[name="event_show_by"]').change(function() {
@@ -60,7 +61,8 @@ var WPEMRestAPIAdmin = (function () {
event_id: jQuery("#event_id").val(),
date_expires: jQuery("#date_expires").val(),
restrict_check_in: jQuery('input[name="restrict_check_in"]').attr("checked") ? 0 : 1,
-
+ event_show_by: jQuery('input[name="event_show_by"]:checked').val(),
+ select_events: jQuery('#select_events').val() || []
},
beforeSend: function (e) {},
success: function (e) {
@@ -72,10 +74,12 @@ var WPEMRestAPIAdmin = (function () {
? (jQuery("#api-keys-options", a.el).parent().remove(),
jQuery("p.submit", a.el).empty().append(e.data.revoke_url),
jQuery("#key-fields p.submit", a.el).before(wp.template("api-keys-template")({ consumer_key: e.data.consumer_key, consumer_secret: e.data.consumer_secret, app_key: e.data.app_key })))
- : (jQuery("#key_description", a.el).val(e.data.description), jQuery("#key_user", a.el).val(e.data.user_id), jQuery("#key_permissions", a.el).val(e.data.permissions)))
+ : (jQuery("#key_description", a.el).val(e.data.description), jQuery("#key_user", a.el).val(e.data.user_id), jQuery("#key_permissions", a.el).val(e.data.permissions),jQuery('input[name="event_show_by"][value="' + e.data.event_show_by + '"]').prop('checked', true),
+ jQuery('#select_events').val(e.data.selected_events).trigger('chosen:updated')))
: jQuery("h2, h3", a.el)
.first()
.append('");
+
},
error: function (e, t, n) {
jQuery("h2, h3", a.el)
diff --git a/assets/js/admin.min.js b/assets/js/admin.min.js
index b1e88e8..672ebc7 100644
--- a/assets/js/admin.min.js
+++ b/assets/js/admin.min.js
@@ -1 +1 @@
-var WPEMRestAPIAdmin={init:function(){var e;function a(){"selected"===jQuery('input[name="event_show_by"]:checked').val()?(jQuery("#select-events-row").show(),jQuery("#select_events").chosen("destroy").chosen()):jQuery("#select-events-row").hide()}jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("#select_events").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}}),a(),jQuery('input[name="event_show_by"]').change((function(){a()}))},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
")},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
+var WPEMRestAPIAdmin={init:function(){var e;function a(){"selected"===jQuery('input[name="event_show_by"]:checked').val()?(jQuery("#select-events-row").show(),jQuery("#select_events").chosen("destroy").chosen()):jQuery("#select-events-row").hide()}jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("#select_events").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}}),a(),jQuery('input[name="event_show_by"]').change((function(){a()}))},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1,event_show_by:jQuery('input[name="event_show_by"]:checked').val(),select_events:jQuery("#select_events").val()||[]},beforeSend:function(e){},success:function(e){console.log(e.data),e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
")},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
From 6c606b4e159b7f8fdd7948d554a094252eb532c5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 4 Jun 2025 18:27:06 +0530
Subject: [PATCH 048/171] #129 Alter table in database
---
wpem-rest-api.php | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 0b1c000..3778acd 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -125,6 +125,8 @@ public function install(){
nonces longtext NULL,
truncated_key char(7) NOT NULL,
last_access datetime NULL default null,
+ event_show_by varchar(20) NULL default 'loggedin',
+ selected_events longtext NULL,
date_created datetime NULL default null,
date_expires datetime NULL default null,
PRIMARY KEY (key_id),
@@ -133,6 +135,20 @@ public function install(){
) $collate;";
dbDelta( $sql );
+
+ // Check if we need to alter existing table
+ $table_name = $wpdb->prefix . 'wpem_rest_api_keys';
+ $columns = $wpdb->get_col("DESC {$table_name}", 0);
+
+ // Add event_show_by column if it doesn't exist
+ if (!in_array('event_show_by', $columns)) {
+ $wpdb->query("ALTER TABLE {$table_name} ADD COLUMN event_show_by varchar(20) NULL DEFAULT 'loggedin'");
+ }
+
+ // Add selected_events column if it doesn't exist
+ if (!in_array('selected_events', $columns)) {
+ $wpdb->query("ALTER TABLE {$table_name} ADD COLUMN selected_events longtext NULL");
+ }
update_option( 'wpem_rest_api_version', WPEM_REST_API_VERSION );
From e3451f0493f8ce0dbb20b2a1634c1f3d0a45f41c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 5 Jun 2025 12:46:11 +0530
Subject: [PATCH 049/171] #129 Need to give selection of the events
---
includes/wpem-rest-crud-controller.php | 54 +++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
index 8733191..ebcea31 100644
--- a/includes/wpem-rest-crud-controller.php
+++ b/includes/wpem-rest-crud-controller.php
@@ -388,7 +388,7 @@ protected function get_objects( $query_args ) {
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
- public function get_items( $request ) {
+ /*public function get_items( $request ) {
$auth_check = $this->wpem_check_authorized_user();
if($auth_check){
return self::prepare_error_for_response(405);
@@ -426,7 +426,57 @@ public function get_items( $request ) {
);
return wp_send_json($response_data);
}
- }
+ }*/
+
+ public function get_items( $request ) {
+ global $wpdb;
+
+ $auth_check = $this->wpem_check_authorized_user();
+ if ($auth_check) {
+ return self::prepare_error_for_response(405);
+ } else {
+
+ $settings_row = $wpdb->get_row("SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys LIMIT 1", ARRAY_A);
+
+ $event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
+ $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];
+
+ $query_args = $this->prepare_objects_query($request);
+
+ if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
+ $query_args['post__in'] = array_map('intval', $selected_events);
+ $query_args['orderby'] = 'post__in';
+ unset($query_args['author']);
+ }
+
+ $query_results = $this->get_objects($query_args);
+
+ $objects = array();
+ foreach ($query_results['objects'] as $object) {
+ $object_id = isset($object->ID) ? $object->ID : $object->get_id();
+
+ if (!wpem_rest_api_check_post_permissions($this->post_type, 'read', $object_id)) {
+ continue;
+ }
+
+ $data = $this->prepare_object_for_response($object, $request);
+ $objects[] = $this->prepare_response_for_collection($data);
+ }
+
+ $page = isset($query_args['paged']) ? (int) $query_args['paged'] : 1;
+ $total_pages = ceil($query_results['total'] / $query_args['posts_per_page']);
+
+ $response_data = self::prepare_error_for_response(200);
+ $response_data['data'] = array(
+ 'total_post_count' => isset($query_results['total']) ? $query_results['total'] : null,
+ 'current_page' => $page,
+ 'last_page' => max(1, $total_pages),
+ 'total_pages' => $total_pages,
+ $this->rest_base => $objects,
+ );
+ return wp_send_json($response_data);
+ }
+ }
/**
* Delete a single item.
From 33a93f78b92b582132117119937fa5abccbafadc Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 5 Jun 2025 16:36:07 +0530
Subject: [PATCH 050/171] #169 change pagination structure in response
---
includes/wpem-rest-matchmaking-filter-users.php | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index c171eb7..81ccf5e 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -350,11 +350,14 @@ public function handle_filter_users($request) {
'code' => 200,
'status' => 'OK',
'message' => 'Users retrieved successfully.',
- 'data' => $results,
- 'total' => $total,
- 'page' => $page,
- 'per_page' => $per_page,
- ], 200);
+ 'data' => [
+ 'total_post_count' => $total,
+ 'current_page' => $page,
+ 'last_page' => ceil($total / $per_page),
+ 'total_pages' => ceil($total / $per_page),
+ 'events' => $results,
+ ],
+ ], 200);
}
}
From 2d6d011b9e693835e338fe7d6d015499c1b6eca9 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 5 Jun 2025 16:42:12 +0530
Subject: [PATCH 051/171] #169
---
includes/wpem-rest-matchmaking-filter-users.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 81ccf5e..fa495a7 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -355,7 +355,7 @@ public function handle_filter_users($request) {
'current_page' => $page,
'last_page' => ceil($total / $per_page),
'total_pages' => ceil($total / $per_page),
- 'events' => $results,
+ 'users' => $results,
],
], 200);
}
From 22328d4124af38274bb2035d474ed5210268081c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 9 Jun 2025 10:04:01 +0530
Subject: [PATCH 052/171] #129 Need to give selection of the events
---
admin/templates/html-keys-edit.php | 21 +++++++++++++++++++++
admin/wpem-rest-api-admin.php | 5 ++++-
assets/js/admin.js | 13 +++++++++++--
assets/js/admin.min.js | 2 +-
4 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/admin/templates/html-keys-edit.php b/admin/templates/html-keys-edit.php
index 231452b..c4e2271 100644
--- a/admin/templates/html-keys-edit.php
+++ b/admin/templates/html-keys-edit.php
@@ -103,6 +103,27 @@
+
+
+
+
+
+
+
+
+ >
+ >
+ >
+ >
+ >
+
+
+
+
+
diff --git a/admin/wpem-rest-api-admin.php b/admin/wpem-rest-api-admin.php
index 64973b5..9b65159 100644
--- a/admin/wpem-rest-api-admin.php
+++ b/admin/wpem-rest-api-admin.php
@@ -113,7 +113,10 @@ public function update_api_key(){
$restrict_check_in = isset( $_POST['restrict_check_in'] ) ? sanitize_text_field( $_POST['restrict_check_in'] ) : '';
$event_show_by = isset($_POST['event_show_by']) ? sanitize_text_field($_POST['event_show_by']) : 'loggedin';
$select_events = isset($_POST['select_events']) ? maybe_serialize(array_map('absint', $_POST['select_events'])) : maybe_serialize(array());
-
+ $mobile_menu = isset($_POST['mobile_menu']) ? array_map('sanitize_text_field', $_POST['mobile_menu']) : array();
+
+ update_user_meta($user_id, '_mobile_menu', $mobile_menu);
+
// Check if current user can edit other users.
if( $user_id && ! current_user_can( 'edit_user', $user_id ) ) {
if( get_current_user_id() !== $user_id ) {
diff --git a/assets/js/admin.js b/assets/js/admin.js
index 276958a..f0c8896 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -62,7 +62,10 @@ var WPEMRestAPIAdmin = (function () {
date_expires: jQuery("#date_expires").val(),
restrict_check_in: jQuery('input[name="restrict_check_in"]').attr("checked") ? 0 : 1,
event_show_by: jQuery('input[name="event_show_by"]:checked').val(),
- select_events: jQuery('#select_events').val() || []
+ select_events: jQuery('#select_events').val() || [],
+ mobile_menu: jQuery('input[name="mobile_menu[]"]:checked').map(function () {
+ return this.value;
+ }).get()
},
beforeSend: function (e) {},
success: function (e) {
@@ -80,7 +83,13 @@ var WPEMRestAPIAdmin = (function () {
.first()
.append('");
- },
+ if (e.data.mobile_menu) {
+ jQuery('input[name="mobile_menu[]"]').prop('checked', false);
+ e.data.mobile_menu.forEach(function (val) {
+ jQuery('input[name="mobile_menu[]"][value="' + val + '"]').prop('checked', true);
+ });
+ }
+ },
error: function (e, t, n) {
jQuery("h2, h3", a.el)
.first()
diff --git a/assets/js/admin.min.js b/assets/js/admin.min.js
index 672ebc7..e397afc 100644
--- a/assets/js/admin.min.js
+++ b/assets/js/admin.min.js
@@ -1 +1 @@
-var WPEMRestAPIAdmin={init:function(){var e;function a(){"selected"===jQuery('input[name="event_show_by"]:checked').val()?(jQuery("#select-events-row").show(),jQuery("#select_events").chosen("destroy").chosen()):jQuery("#select-events-row").hide()}jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("#select_events").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}}),a(),jQuery('input[name="event_show_by"]').change((function(){a()}))},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1,event_show_by:jQuery('input[name="event_show_by"]:checked').val(),select_events:jQuery("#select_events").val()||[]},beforeSend:function(e){},success:function(e){console.log(e.data),e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
")},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
+var WPEMRestAPIAdmin={init:function(){var e;function a(){"selected"===jQuery('input[name="event_show_by"]:checked').val()?(jQuery("#select-events-row").show(),jQuery("#select_events").chosen("destroy").chosen()):jQuery("#select-events-row").hide()}jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("#select_events").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}}),a(),jQuery('input[name="event_show_by"]').change((function(){a()}))},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1,event_show_by:jQuery('input[name="event_show_by"]:checked').val(),select_events:jQuery("#select_events").val()||[],mobile_menu:jQuery('input[name="mobile_menu[]"]:checked').map((function(){return this.value})).get()},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
"),e.data.mobile_menu&&(jQuery('input[name="mobile_menu[]"]').prop("checked",!1),e.data.mobile_menu.forEach((function(e){jQuery('input[name="mobile_menu[]"][value="'+e+'"]').prop("checked",!0)})))},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
From 657871d5d53b5af47bc9610a12ff15cb7df015a5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 9 Jun 2025 10:10:44 +0530
Subject: [PATCH 053/171] #129 Need to give selection of the events
---
includes/wpem-rest-authentication.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index f3c3be6..0669f4d 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -688,6 +688,15 @@ public function perform_user_authentication($request){
$token = $this->wpem_generate_jwt_token($user->ID);
$is_matchmaking = get_user_meta($user_id, '_matchmaking_profile', true);
$enable_matchmaking = get_option('enable_matchmaking', false) ? 1 : 0;
+
+ $all_mobile_pages = array( 'dashboard', 'attendees', 'guest_list', 'orders', 'arrivals' );
+ $user_mobile_menu = get_user_meta($user_id, '_mobile_menu', true);
+ $user_mobile_menu = is_array($user_mobile_menu) ? $user_mobile_menu : [];
+
+ $mobile_menu_status = array();
+ foreach ( $all_mobile_pages as $page ) {
+ $mobile_menu_status[ $page ] = in_array( $page, $user_mobile_menu ) ? 1 : 0;
+ }
$data = array(
'token' => $token,
@@ -699,6 +708,7 @@ public function perform_user_authentication($request){
'username' => $user->user_login,
'matchmaking_profile' => $is_matchmaking,
'enable_matchmaking' => $enable_matchmaking,
+ 'mobile_menu' => $mobile_menu_status,
)
);
if ($is_matchmaking && $enable_matchmaking ) {
From ba36a46aa78ae6f8632f8753ec59ef683da866b2 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 12 Jun 2025 13:00:24 +0530
Subject: [PATCH 054/171] #146 Changes in send message api
---
.../wpem-rest-matchmaking-user-messages.php | 24 ++++++++-----------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 420b186..0f94f0c 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -20,7 +20,6 @@ public function register_routes() {
'senderId' => array('required' => true, 'type' => 'integer'),
'receiverId' => array('required' => true, 'type' => 'integer'),
'message' => array('required' => true, 'type' => 'string'),
- 'eventId' => array('required' => false, 'type' => 'integer'),
),
));
@@ -50,7 +49,6 @@ public function handle_send_message($request) {
$sender_id = intval($request->get_param('senderId'));
$receiver_id = intval($request->get_param('receiverId'));
$message = sanitize_textarea_field($request->get_param('message'));
- $event_id = intval($request->get_param('eventId'));
$sender_user = get_user_by('id', $sender_id);
$receiver_user = get_user_by('id', $receiver_id);
@@ -88,25 +86,24 @@ public function handle_send_message($request) {
$table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
$today = date('Y-m-d');
- $existing = $wpdb->get_var($wpdb->prepare(
- "SELECT COUNT(*) FROM $table
- WHERE sender_id = %d AND receiver_id = %d
- AND DATE(created_at) = %s",
- $sender_id, $receiver_id, $today
- ));
+ $first_message_id = $wpdb->get_var($wpdb->prepare(
+ "SELECT id FROM $table
+ WHERE (sender_id = %d AND receiver_id = %d)
+ OR (sender_id = %d AND receiver_id = %d)
+ ORDER BY created_at ASC LIMIT 1",
+ $sender_id, $receiver_id,
+ $receiver_id, $sender_id
+ ));
- $parent_id = ($existing == 0) ? 1 : 0;
+ $parent_id = $first_message_id ? $first_message_id : 0;
$inserted = $wpdb->insert($table, array(
- 'event_id' => $event_id,
'parent_id' => $parent_id,
'sender_id' => $sender_id,
'receiver_id' => $receiver_id,
- 'first_name' => $first_name,
- 'last_name' => $last_name,
'message' => $message,
'created_at' => current_time('mysql')
- ), array('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s'));
+ ), array('%d', '%d', '%d', '%s', '%s'));
if (!$inserted) {
return new WP_REST_Response([
@@ -130,7 +127,6 @@ public function handle_send_message($request) {
'message' => 'Message sent and saved successfully.',
'data' => array(
'id' => $wpdb->insert_id,
- 'event_id' => $event_id,
'parent_id' => $parent_id,
'sender_id' => $sender_id,
'receiver_id'=> $receiver_id,
From 35283d92a6480e1f840820cb892bfecd1fdd49e5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 12 Jun 2025 13:52:09 +0530
Subject: [PATCH 055/171] #146 Add pagination in get message api
---
.../wpem-rest-matchmaking-user-messages.php | 92 ++++++++++++-------
1 file changed, 58 insertions(+), 34 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 0f94f0c..2e77663 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -30,6 +30,8 @@ public function register_routes() {
'args' => array(
'senderId' => array('required' => true, 'type' => 'integer'),
'receiverId' => array('required' => true, 'type' => 'integer'),
+ 'page' => array('required' => false, 'type' => 'integer', 'default' => 1),
+ 'per_page' => array('required' => false, 'type' => 'integer', 'default' => 20),
),
));
}
@@ -139,46 +141,68 @@ public function handle_send_message($request) {
}
public function handle_get_messages($request) {
- global $wpdb;
+ global $wpdb;
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response(array(
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ), 403);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response(array(
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ), 403);
+ }
- $sender_id = intval($request->get_param('senderId'));
- $receiver_id = intval($request->get_param('receiverId'));
+ $sender_id = intval($request->get_param('senderId'));
+ $receiver_id = intval($request->get_param('receiverId'));
+ $page = max(1, intval($request->get_param('page')));
+ $per_page = max(1, intval($request->get_param('per_page')));
- if (!$sender_id || !$receiver_id) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'Bad Request',
- 'message' => 'senderId and receiverId are required.',
- 'data' => null
- ], 400);
- }
+ if (!$sender_id || !$receiver_id) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'senderId and receiverId are required.',
+ 'data' => null
+ ], 400);
+ }
- $table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
+ $offset = ($page - 1) * $per_page;
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
- $messages = $wpdb->get_results($wpdb->prepare(
- "SELECT * FROM $table
- WHERE (sender_id = %d AND receiver_id = %d)
- OR (sender_id = %d AND receiver_id = %d)
- ORDER BY created_at ASC",
- $sender_id, $receiver_id, $receiver_id, $sender_id
- ), ARRAY_A);
+ // Get total message count
+ $total_messages = $wpdb->get_var($wpdb->prepare(
+ "SELECT COUNT(*) FROM $table
+ WHERE (sender_id = %d AND receiver_id = %d)
+ OR (sender_id = %d AND receiver_id = %d)",
+ $sender_id, $receiver_id, $receiver_id, $sender_id
+ ));
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Messages retrieved successfully.',
- 'data' => $messages
- ], 200);
- }
+ // Get paginated messages
+ $messages = $wpdb->get_results($wpdb->prepare(
+ "SELECT * FROM $table
+ WHERE (sender_id = %d AND receiver_id = %d)
+ OR (sender_id = %d AND receiver_id = %d)
+ ORDER BY created_at ASC
+ LIMIT %d OFFSET %d",
+ $sender_id, $receiver_id, $receiver_id, $sender_id,
+ $per_page, $offset
+ ), ARRAY_A);
+
+ $total_pages = ceil($total_messages / $per_page);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Messages retrieved successfully.',
+ 'data' => [
+ 'total_page_count' => intval($total_messages),
+ 'current_page' => $page,
+ 'last_page' => $total_pages,
+ 'total_pages' => $total_pages,
+ 'messages' => $messages,
+ ]
+ ], 200);
+ }
}
new WPEM_REST_Send_Message_Controller();
From 78793a72d45ae2f1d4d7adf4ad2e8e3ddbeaf305 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 12 Jun 2025 15:12:39 +0530
Subject: [PATCH 056/171] #146 Create Conversation list api
---
.../wpem-rest-matchmaking-user-messages.php | 122 ++++++++++++++++++
1 file changed, 122 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 2e77663..54693c4 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -34,6 +34,18 @@ public function register_routes() {
'per_page' => array('required' => false, 'type' => 'integer', 'default' => 20),
),
));
+ // Get conversation list endpoint
+ register_rest_route($this->namespace, '/get-conversation-list', array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'handle_get_conversation_list'),
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
+ 'args' => array(
+ 'user_id' => array('required' => true, 'type' => 'integer'),
+ 'event_ids' => array('required' => true, 'type' => 'array', 'items' => array('type' => 'integer')),
+ 'paged' => array('required' => false, 'type' => 'integer', 'default' => 1),
+ 'per_page' => array('required' => false, 'type' => 'integer', 'default' => 10),
+ ),
+ ));
}
public function handle_send_message($request) {
@@ -203,6 +215,116 @@ public function handle_get_messages($request) {
]
], 200);
}
+ public function handle_get_conversation_list($request) {
+ global $wpdb;
+
+ $user_id = intval($request->get_param('user_id'));
+ $event_ids = $request->get_param('event_ids'); // expects an array
+ $paged = max(1, intval($request->get_param('paged')));
+ $per_page = max(1, intval($request->get_param('per_page')));
+
+ if (empty($user_id) || empty($event_ids) || !is_array($event_ids)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'user_id and event_ids[] are required.',
+ ], 400);
+ }
+
+ $postmeta = $wpdb->postmeta;
+ $messages_tbl = $wpdb->prefix . 'wpem_matchmaking_users_messages';
+ $profile_tbl = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ // Step 1: Get users registered in the same events (excluding self)
+ $event_placeholders = implode(',', array_fill(0, count($event_ids), '%d'));
+ $registered_user_ids = $wpdb->get_col($wpdb->prepare("
+ SELECT DISTINCT pm2.meta_value
+ FROM $postmeta pm1
+ INNER JOIN $postmeta pm2 ON pm1.post_id = pm2.post_id
+ WHERE pm1.meta_key = '_event_id'
+ AND pm1.meta_value IN ($event_placeholders)
+ AND pm2.meta_key = '_attendee_user_id'
+ AND pm2.meta_value != %d
+ ", array_merge($event_ids, [ $user_id ])));
+
+ if (empty($registered_user_ids)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No users registered in the same events.',
+ 'data' => []
+ ], 200);
+ }
+
+ // Step 2: Get users who have messaged with current user
+ $messaged_user_ids = $wpdb->get_col($wpdb->prepare("
+ SELECT DISTINCT user_id FROM (
+ SELECT sender_id AS user_id FROM $messages_tbl WHERE receiver_id = %d
+ UNION
+ SELECT receiver_id AS user_id FROM $messages_tbl WHERE sender_id = %d
+ ) AS temp
+ WHERE user_id != %d
+ ", $user_id, $user_id, $user_id));
+
+ if (empty($messaged_user_ids)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No message history found.',
+ 'data' => []
+ ], 200);
+ }
+
+ // Step 3: Intersect both lists
+ $valid_user_ids = array_values(array_intersect($registered_user_ids, $messaged_user_ids));
+
+ $total_count = count($valid_user_ids);
+ if ($total_count === 0) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No matched users found.',
+ 'data' => [
+ 'total_users' => 0,
+ 'current_page' => $paged,
+ 'total_pages' => 0,
+ 'users' => []
+ ]
+ ], 200);
+ }
+
+ // Step 4: Paginate
+ $offset = ($paged - 1) * $per_page;
+ $paginated_ids = array_slice($valid_user_ids, $offset, $per_page);
+
+ // Step 5: Build user info
+ $results = [];
+ foreach ($paginated_ids as $uid) {
+ $results[] = [
+ 'user_id' => (int) $uid,
+ 'first_name' => get_user_meta($uid, 'first_name', true),
+ 'last_name' => get_user_meta($uid, 'last_name', true),
+ 'profile_photo'=> $wpdb->get_var($wpdb->prepare("SELECT profile_photo FROM $profile_tbl WHERE user_id = %d", $uid)),
+ 'profession' => $wpdb->get_var($wpdb->prepare("SELECT profession FROM $profile_tbl WHERE user_id = %d", $uid)),
+ 'company_name' => $wpdb->get_var($wpdb->prepare("SELECT company_name FROM $profile_tbl WHERE user_id = %d", $uid)),
+ ];
+ }
+
+ $last_page = ceil($total_count / $per_page);
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Filtered users retrieved.',
+ 'data' => [
+ 'total_users' => $total_count,
+ 'current_page' => $paged,
+ 'per_page' => $per_page,
+ 'last_page' => $last_page,
+ 'users' => $results
+ ]
+ ], 200);
+ }
+
}
new WPEM_REST_Send_Message_Controller();
From df21fd48bf081de1502bbe98656536aefe66025d Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 13 Jun 2025 12:14:46 +0530
Subject: [PATCH 057/171] #146 API Changes in Get Conversation list api
---
.../wpem-rest-matchmaking-user-messages.php | 27 +++++++++++++------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 54693c4..36adc24 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -297,20 +297,32 @@ public function handle_get_conversation_list($request) {
$offset = ($paged - 1) * $per_page;
$paginated_ids = array_slice($valid_user_ids, $offset, $per_page);
- // Step 5: Build user info
+ // Step 5: Build user info with last message
$results = [];
foreach ($paginated_ids as $uid) {
+ // Get last message exchanged
+ $last_message_row = $wpdb->get_row($wpdb->prepare("
+ SELECT message, created_at
+ FROM $messages_tbl
+ WHERE (sender_id = %d AND receiver_id = %d) OR (sender_id = %d AND receiver_id = %d)
+ ORDER BY created_at DESC
+ LIMIT 1
+ ", $user_id, $uid, $uid, $user_id));
+
$results[] = [
- 'user_id' => (int) $uid,
- 'first_name' => get_user_meta($uid, 'first_name', true),
- 'last_name' => get_user_meta($uid, 'last_name', true),
- 'profile_photo'=> $wpdb->get_var($wpdb->prepare("SELECT profile_photo FROM $profile_tbl WHERE user_id = %d", $uid)),
- 'profession' => $wpdb->get_var($wpdb->prepare("SELECT profession FROM $profile_tbl WHERE user_id = %d", $uid)),
- 'company_name' => $wpdb->get_var($wpdb->prepare("SELECT company_name FROM $profile_tbl WHERE user_id = %d", $uid)),
+ 'user_id' => (int) $uid,
+ 'first_name' => get_user_meta($uid, 'first_name', true),
+ 'last_name' => get_user_meta($uid, 'last_name', true),
+ 'profile_photo' => $wpdb->get_var($wpdb->prepare("SELECT profile_photo FROM $profile_tbl WHERE user_id = %d", $uid)),
+ 'profession' => $wpdb->get_var($wpdb->prepare("SELECT profession FROM $profile_tbl WHERE user_id = %d", $uid)),
+ 'company_name' => $wpdb->get_var($wpdb->prepare("SELECT company_name FROM $profile_tbl WHERE user_id = %d", $uid)),
+ 'last_message' => $last_message_row ? $last_message_row->message : null,
+ 'message_time' => $last_message_row ? date('d/m/y, h:i A', strtotime($last_message_row->created_at)) : null,
];
}
$last_page = ceil($total_count / $per_page);
+
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
@@ -324,7 +336,6 @@ public function handle_get_conversation_list($request) {
]
], 200);
}
-
}
new WPEM_REST_Send_Message_Controller();
From 1edcf1c1d9907fc99acdbfb0eb8aba2d8608b473 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 16 Jun 2025 16:25:14 +0530
Subject: [PATCH 058/171] #145
---
includes/wpem-rest-matchmaking-user-messages.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 36adc24..3571a16 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -194,7 +194,7 @@ public function handle_get_messages($request) {
"SELECT * FROM $table
WHERE (sender_id = %d AND receiver_id = %d)
OR (sender_id = %d AND receiver_id = %d)
- ORDER BY created_at ASC
+ ORDER BY created_at DESC
LIMIT %d OFFSET %d",
$sender_id, $receiver_id, $receiver_id, $sender_id,
$per_page, $offset
From de5b08bf72abf9cfed004a784a377fb4eccecdc3 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 16 Jun 2025 18:27:37 +0530
Subject: [PATCH 059/171] #145 APIs For Let's Meet Feature
---
.../wpem-rest-matchmaking-create-meetings.php | 527 +++++++++---------
1 file changed, 252 insertions(+), 275 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index f53c866..cd39aed 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -10,12 +10,12 @@ public function __construct() {
}
public function register_routes() {
- $auth_controller = new WPEM_REST_Authentication();
- // Create Meeting
+ $auth_controller = new WPEM_REST_Authentication();
+
register_rest_route($this->namespace, '/' . $this->rest_base, [
'methods' => WP_REST_Server::CREATABLE,
'callback' => [$this, 'create_meeting'],
- 'permission_callback' => array($auth_controller, 'check_authentication'),
+ 'permission_callback' => [$auth_controller, 'check_authentication'],
'args' => [
'user_id' => ['required' => true, 'type' => 'integer'],
'event_id' => ['required' => true, 'type' => 'integer'],
@@ -27,310 +27,287 @@ public function register_routes() {
],
]);
- // Get Meetings
register_rest_route($this->namespace, '/get-meetings', [
'methods' => WP_REST_Server::CREATABLE,
'callback' => [$this, 'get_user_meetings'],
- 'permission_callback' => array($auth_controller, 'check_authentication'),
+ 'permission_callback' => [$auth_controller, 'check_authentication'],
]);
+ register_rest_route($this->namespace, '/cancel-meeting', [
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => [$this, 'cancel_meeting'],
+ 'permission_callback' => [$auth_controller, 'check_authentication'],
+ 'args' => [
+ 'meeting_id' => ['required' => true, 'type' => 'integer'],
+ 'user_id' => ['required' => true, 'type' => 'integer'],
+ ],
+ ]);
}
public function create_meeting(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
- global $wpdb;
-
- $user_id = intval($request->get_param('user_id'));
- $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
- $start_time = sanitize_text_field($request->get_param('meeting_start_time'));
- $end_time = sanitize_text_field($request->get_param('meeting_end_time'));
- $participants = $request->get_param('meeting_participants');
- $message = sanitize_textarea_field($request->get_param('write_a_message'));
- $event_id = intval($request->get_param('event_id'));
-
- if (!$user_id || !get_userdata($user_id)) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'Bad Request',
- 'message' => 'Invalid user.',
- 'data' => []
- ], 400);
- }
-
- if (empty($meeting_date) || empty($start_time) || empty($end_time) || empty($participants) || !is_array($participants)) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'Bad Request',
- 'message' => 'Missing or invalid parameters.',
- 'data' => []
- ], 400);
- }
-
- // Remove self from participants
- $participants = array_filter(array_map('intval', $participants), function ($pid) use ($user_id) {
- return $pid !== $user_id;
- });
-
- $meeting_table_name = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $inserted = $wpdb->insert(
- $meeting_table_name,
- [
- 'user_id' => $user_id,
- 'event_id' => $event_id,
- 'participant_ids' => implode(',', $participants),
- 'meeting_date' => $meeting_date,
- 'meeting_start_time' => $start_time,
- 'meeting_end_time' => $end_time,
- 'message' => $message,
- 'meeting_status' => 0
- ],
- ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']
- );
-
- if (!$inserted) {
- return new WP_REST_Response([
- 'code' => 500,
- 'status' => 'Internal Server Error',
- 'message' => 'Could not create meeting. Please try again.',
- 'data' => []
- ], 500);
- }
-
- $meeting_id = $wpdb->insert_id;
-
- $formatted_date = date("l, d F Y", strtotime($meeting_date));
- $formatted_start_time = date("h:i A", strtotime($start_time));
- $formatted_end_time = date("h:i A", strtotime($end_time));
-
- $participant_details = [];
- $sender_user = get_userdata($user_id);
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response(['code' => 403, 'status' => 'Disabled', 'message' => 'Matchmaking functionality is not enabled.', 'data' => null], 403);
+ }
+
+ global $wpdb;
+
+ $user_id = intval($request->get_param('user_id'));
+ $event_id = intval($request->get_param('event_id'));
+ $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
+ $start_time = sanitize_text_field($request->get_param('meeting_start_time'));
+ $end_time = sanitize_text_field($request->get_param('meeting_end_time'));
+ $participants = $request->get_param('meeting_participants');
+ $message = sanitize_textarea_field($request->get_param('write_a_message'));
+
+ if (!$user_id || !get_userdata($user_id) || empty($meeting_date) || empty($start_time) || empty($end_time) || empty($participants) || !is_array($participants)) {
+ return new WP_REST_Response(['code' => 400, 'status' => 'Bad Request', 'message' => 'Missing or invalid parameters.', 'data' => []], 400);
+ }
+
+ // Filter out the user themselves from participant list
+ $participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $inserted = $wpdb->insert($table, [
+ 'user_id' => $user_id,
+ 'event_id' => $event_id,
+ 'participant_ids' => implode(',', $participants),
+ 'meeting_date' => $meeting_date,
+ 'meeting_start_time' => $start_time,
+ 'meeting_end_time' => $end_time,
+ 'message' => $message,
+ 'meeting_status' => 0
+ ], ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']);
+
+ if (!$inserted) {
+ return new WP_REST_Response(['code' => 500, 'status' => 'Internal Server Error', 'message' => 'Could not create meeting.', 'data' => []], 500);
+ }
+
+ $meeting_id = $wpdb->insert_id;
+ $formatted_date = date("l, d F Y", strtotime($meeting_date));
+ $formatted_start_time = date("h:i A", strtotime($start_time));
+ $formatted_end_time = date("h:i A", strtotime($end_time));
+ $sender_user = get_userdata($user_id);
+
+ $participant_details = [];
+
+ if (!empty($participants)) {
+ $profile_table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $placeholders = implode(',', array_fill(0, count($participants), '%d'));
+ $query = $wpdb->prepare("SELECT * FROM $profile_table WHERE user_id IN ($placeholders)", ...$participants);
+ $results = $wpdb->get_results($query, ARRAY_A);
+
+ foreach ($results as $participant) {
+ $participant_user = get_userdata($participant['user_id']);
+ $participant_name = $participant_user->display_name ?? 'User';
+ $participant_email = $participant_user->user_email ?? '';
+ $profile_picture = $participant['profile_photo'] ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
+
+ $participant_details[] = [
+ 'name' => $participant_name,
+ 'profession' => $participant['profession'] ?? '',
+ 'profile_picture' => esc_url($profile_picture)
+ ];
+
+ // Email to participant
+ $host_profile = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d", $user_id), ARRAY_A);
+ $host_company = $host_profile['company_name'] ?? '';
+ $host_city = $host_profile['city'] ?? '';
+ $all_countries = wpem_registration_get_all_countries();
+ $host_country = $all_countries[$host_profile['country']] ?? '';
+ $event_name = get_the_title($event_id) ?: '';
+ $timezone_abbr = wp_timezone_string();
+
+ $subject = "{$sender_user->display_name} requested a meeting with you";
+ $body = "
+ Hello {$participant_name},
+ {$sender_user->display_name} has requested a meeting with you.
+ Event: {$event_name}
+ Date: {$formatted_date}
+ Time: {$formatted_start_time} – {$formatted_end_time} {$timezone_abbr}
+ Company: {$host_company}
+ City: {$host_city}
+ Country: {$host_country}
+ Message: {$message}
+ ";
+
+ wp_mail($participant_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
+ }
+ }
+
+ // Email to sender
+ $participant_names = implode(', ', array_column($participant_details, 'name'));
+ wp_mail(
+ $sender_user->user_email,
+ 'Your Meeting Request Has Been Sent',
+ "
+ Hello {$sender_user->display_name},
+ Your meeting request has been sent to: {$participant_names} .
+ Date: {$formatted_date}
+ Time: {$formatted_start_time} - {$formatted_end_time}
+ Message: {$message}
+ ",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meeting created and emails sent!',
+ 'data' => [
+ 'meeting_date' => $formatted_date,
+ 'start_time' => $formatted_start_time,
+ 'end_time' => $formatted_end_time,
+ 'participants' => $participant_details,
+ 'message' => $message
+ ]
+ ], 200);
+ }
- if (!empty($participants)) {
- $table_name = $wpdb->prefix . 'wpem_matchmaking_users';
- $placeholders = implode(',', array_fill(0, count($participants), '%d'));
- $query = $wpdb->prepare("SELECT * FROM $table_name WHERE user_id IN ($placeholders)", ...$participants);
- $results = $wpdb->get_results($query, ARRAY_A);
+ public function get_user_meetings(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response(['code' => 403, 'status' => 'Disabled', 'message' => 'Matchmaking functionality is not enabled.', 'data' => null], 403);
+ }
+
+ global $wpdb;
+
+ $event_id = intval($request->get_param('event_id'));
+ $user_id = intval($request->get_param('user_id'));
+ $participants_id = $request->get_param('participants_id');
+
+ if (!$event_id || !$user_id || empty($participants_id)) {
+ return new WP_REST_Response(['code' => 400, 'status' => 'error', 'message' => 'Missing event_id, user_id, or participants_id.', 'data' => null], 400);
+ }
+
+ $participants_id = is_array($participants_id) ? array_map('intval', $participants_id) : array_map('intval', explode(',', $participants_id));
+
+ $conditions = [];
+ foreach ($participants_id as $id) {
+ $conditions[] = $wpdb->prepare("FIND_IN_SET(%d, participant_ids)", $id);
+ }
+ $where_participants = implode(" OR ", $conditions);
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $sql = "
+ SELECT * FROM $table
+ WHERE event_id = %d
+ AND (user_id = %d OR ($where_participants))
+ ";
+ $query = $wpdb->prepare($sql, $event_id, $user_id);
+ $meetings = $wpdb->get_results($query, ARRAY_A);
+
+ if (empty($meetings)) {
+ return new WP_REST_Response(['code' => 404, 'status' => 'error', 'message' => 'No meetings found.', 'data' => null], 404);
+ }
+
+ // Collect all user IDs involved
+ $all_user_ids = [$user_id];
+ foreach ($meetings as $meeting) {
+ $all_user_ids = array_merge($all_user_ids, array_map('intval', explode(',', $meeting['participant_ids'])));
+ }
+ $all_user_ids = array_unique($all_user_ids);
+
+ $profiles = $wpdb->get_results(
+ $wpdb->prepare("SELECT user_id, profession, profile_photo FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id IN (" . implode(',', array_fill(0, count($all_user_ids), '%d')) . ")", ...$all_user_ids),
+ ARRAY_A
+ );
+ $custom_user_indexed = array_column($profiles, null, 'user_id');
+
+ $meeting_data = [];
+ foreach ($meetings as $meeting) {
+ $participant_array = maybe_unserialize($meeting['participant_ids']);
+ $participants_info = [];
- foreach ($results as $participant) {
- $user_data = get_userdata($participant['user_id']);
- $profile_picture_url = $participant['profile_photo'] ?? '';
- if (empty($profile_picture_url)) {
- $profile_picture_url = EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
+ if (is_array($participant_array)) {
+ foreach ($participant_array as $pid => $status) {
+ if ((int)$pid !== $user_id) {
+ $participants_info[] = [
+ 'id' => (int)$pid,
+ 'status' => (int)$status,
+ ];
+ }
}
-
- $participant_details[] = [
- 'name' => $user_data ? $user_data->display_name : '',
- 'profession' => $participant['profession'] ?? '',
- 'profile_picture' => $profile_picture_url
- ];
-
- // Email to participant
- $token = wp_create_nonce("meeting_action_{$meeting_id}_{$participant['user_id']}");
- $confirm_url = add_query_arg([
- 'meeting_action' => 'confirm',
- 'meeting_id' => $meeting_id,
- 'user_id' => $participant['user_id'],
- 'token' => $token,
- ], home_url('/'));
-
- $decline_url = add_query_arg([
- 'meeting_action' => 'decline',
- 'meeting_id' => $meeting_id,
- 'user_id' => $participant['user_id'],
- 'token' => $token,
- ], home_url('/'));
-
- $host_profile = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d", $user_id), ARRAY_A);
- $host_company = $host_profile['company_name'] ?? '';
- $host_city = $host_profile['city'] ?? '';
- $all_countries = wpem_registration_get_all_countries();
- $host_country = $all_countries[$host_profile['country']] ?? '';
- $event_name = ''; // You can pull this dynamically if needed
- $timezone_abbr = wp_timezone_string();
-
- $subject = "{$sender_user->display_name} requested a meeting with you";
- $body = "
- Hello {$user_data->display_name},
- {$sender_user->display_name} has requested a meeting with you.
- Event: {$event_name}
- Date: {$formatted_date}
- Time: {$formatted_start_time} – {$formatted_end_time} {$timezone_abbr}
- Company: {$host_company}
- City: {$host_city}
- Country: {$host_country}
- Message: {$message}
-
- Confirm |
- Decline
-
- ";
-
- wp_mail($user_data->user_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
}
- }
-
- // Email to sender
- $participant_names = implode(', ', array_column($participant_details, 'name'));
- $cancel_token = wp_create_nonce("cancel_meeting_{$meeting_id}_{$user_id}");
- $cancel_url = add_query_arg([
- 'meeting_action' => 'cancel',
- 'meeting_id' => $meeting_id,
- 'user_id' => $user_id,
- 'token' => $cancel_token,
- ], home_url('/'));
-
- wp_mail(
- $sender_user->user_email,
- 'Your Meeting Request Has Been Sent',
- "
- Hello {$sender_user->display_name},
- Your meeting request has been sent to: {$participant_names} .
- Date: {$formatted_date}
- Time: {$formatted_start_time} - {$formatted_end_time}
- Message: {$message}
- Cancel Meeting
- ",
- ['Content-Type: text/html; charset=UTF-8']
- );
-
- // Final Success Response
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Meeting created and emails sent!',
- 'data' => [
- 'meeting_date' => $formatted_date,
- 'start_time' => $formatted_start_time,
- 'end_time' => $formatted_end_time,
- 'participants' => $participant_details,
- 'message' => $message
- ]
- ], 200);
- }
- public function get_user_meetings(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
+ $meeting_data[] = [
+ 'meeting_id' => (int)$meeting['id'],
+ 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
+ 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
+ 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
+ 'message' => $meeting['message'],
+ 'host' => (int)$meeting['user_id'],
+ 'participants' => $participants_info,
+ ];
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meetings retrieved successfully.',
+ 'data' => $meeting_data,
+ ], 200);
+ }
+ public function cancel_meeting(WP_REST_Request $request) {
global $wpdb;
- $event_id = $request->get_param('event_id');
- $user_id = intval($request->get_param('user_id'));
- $participants_id = $request->get_param('participants_id');
-
- if (!$event_id || !$user_id || empty($participants_id)) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'error',
- 'message' => 'Missing event_id, user_id, or participants_id.',
- 'data' => null,
- ], 400);
- }
-
- // Normalize participants_id as array
- if (!is_array($participants_id)) {
- $participants_id = array_map('intval', explode(',', $participants_id));
- }
+ $meeting_id = intval($request->get_param('meeting_id'));
+ $user_id = intval($request->get_param('user_id'));
- // Build dynamic FIND_IN_SET conditions
- $conditions = [];
- foreach ($participants_id as $id) {
- $conditions[] = $wpdb->prepare("FIND_IN_SET(%d, participant_ids)", $id);
+ if (!$meeting_id || !$user_id) {
+ return new WP_REST_Response(['code' => 400, 'status' => 'error', 'message' => 'Missing meeting_id or user_id.'], 400);
}
- $where_participants = implode(" OR ", $conditions);
- // Query all matching meetings
$table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $sql = "
- SELECT * FROM $table
- WHERE event_id = %d
- AND user_id = %d
- AND ($where_participants)
- ";
- $query = $wpdb->prepare($sql, $event_id, $user_id);
- $meetings = $wpdb->get_results($query, ARRAY_A);
-
- if (empty($meetings)) {
- return new WP_REST_Response([
- 'code' => 404,
- 'status' => 'error',
- 'message' => 'No meetings found for the given input.',
- 'data' => null,
- ], 404);
- }
+ $meeting = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE id = %d", $meeting_id), ARRAY_A);
- // Collect all unique user IDs involved (host + participants)
- $all_user_ids = [$user_id];
- foreach ($meetings as $meeting) {
- $ids = array_map('intval', explode(',', $meeting['participant_ids']));
- $all_user_ids = array_merge($all_user_ids, $ids);
+ if (!$meeting) {
+ return new WP_REST_Response(['code' => 404, 'status' => 'error', 'message' => 'Meeting not found.'], 404);
}
- $all_user_ids = array_unique($all_user_ids);
-
- // Fetch data from custom matchmaking user table
- $custom_user_data = $wpdb->get_results(
- $wpdb->prepare(
- "SELECT user_id, profession, profile_photo FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id IN (" . implode(',', array_fill(0, count($all_user_ids), '%d')) . ")",
- ...$all_user_ids
- ),
- ARRAY_A
- );
- $custom_user_indexed = [];
- foreach ($custom_user_data as $u) {
- $custom_user_indexed[$u['user_id']] = $u;
+
+ if ((int)$meeting['user_id'] !== $user_id) {
+ return new WP_REST_Response(['code' => 403, 'status' => 'error', 'message' => 'Only the host can cancel the meeting.'], 403);
}
- // Helper to get user info
- $get_user_info = function($uid) use ($custom_user_indexed) {
- $first_name = get_user_meta($uid, 'first_name', true);
- $last_name = get_user_meta($uid, 'last_name', true);
- return [
- 'user_id' => $uid,
- 'name' => trim("$first_name $last_name") ?: 'Unknown',
- 'profession' => $custom_user_indexed[$uid]['profession'] ?? '',
- 'profile_picture' => esc_url($custom_user_indexed[$uid]['profile_photo'] ?? ''),
- ];
- };
+ $updated = $wpdb->update($table, ['meeting_status' => -1], ['id' => $meeting_id], ['%d'], ['%d']);
- // Final meetings list
- $meeting_data = [];
+ if (!$updated) {
+ return new WP_REST_Response(['code' => 500, 'status' => 'error', 'message' => 'Failed to cancel meeting.'], 500);
+ }
- foreach ($meetings as $meeting) {
- $participant_ids = array_map('intval', explode(',', $meeting['participant_ids']));
- $participants_info = [];
+ // Notify participants
+ $participant_ids = maybe_unserialize($meeting['participant_ids']);
+ if (!is_array($participant_ids)) {
+ $participant_ids = [];
+ }
- foreach ($participant_ids as $pid) {
- if ($pid !== $user_id) {
- $participants_info[] = $get_user_info($pid);
- }
+ foreach ($participant_ids as $pid => $status) {
+ $user = get_userdata($pid);
+ if ($user) {
+ wp_mail(
+ $user->user_email,
+ 'Meeting Cancelled',
+ "Hello {$user->display_name},
+ The meeting scheduled on {$meeting['meeting_date']} has been cancelled .
",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
}
+ }
- $meeting_data[] = [
- 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
- 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
- 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
- 'message' => $meeting['message'] ?? '',
- 'host' => $get_user_info($user_id),
- 'participants' => $participants_info,
- ];
+ // Notify host
+ $host = get_userdata($user_id);
+ if ($host) {
+ wp_mail(
+ $host->user_email,
+ 'You Cancelled a Meeting',
+ "Hello {$host->display_name},
+ You have cancelled the meeting scheduled on {$meeting['meeting_date']} .
",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
}
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
- 'message' => 'Meetings retrieved successfully.',
- 'data' => $meeting_data,
+ 'message' => 'Meeting cancelled successfully.',
+ 'data' => ['meeting_id' => $meeting_id],
], 200);
}
}
From 401b3d2166033c5d00e9f7b641fa89e7331b1c5c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 16 Jun 2025 18:51:36 +0530
Subject: [PATCH 060/171] #145 APIs For Let's Meet Feature
---
.../wpem-rest-matchmaking-create-meetings.php | 148 +++++++++---------
1 file changed, 77 insertions(+), 71 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index cd39aed..894d828 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -163,88 +163,94 @@ public function create_meeting(WP_REST_Request $request) {
}
public function get_user_meetings(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response(['code' => 403, 'status' => 'Disabled', 'message' => 'Matchmaking functionality is not enabled.', 'data' => null], 403);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
- global $wpdb;
+ global $wpdb;
- $event_id = intval($request->get_param('event_id'));
- $user_id = intval($request->get_param('user_id'));
- $participants_id = $request->get_param('participants_id');
+ $event_id = intval($request->get_param('event_id'));
+ $user_id = intval($request->get_param('user_id'));
- if (!$event_id || !$user_id || empty($participants_id)) {
- return new WP_REST_Response(['code' => 400, 'status' => 'error', 'message' => 'Missing event_id, user_id, or participants_id.', 'data' => null], 400);
- }
+ if (!$event_id || !$user_id) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'error',
+ 'message' => 'Missing event_id or user_id.',
+ 'data' => null
+ ], 400);
+ }
- $participants_id = is_array($participants_id) ? array_map('intval', $participants_id) : array_map('intval', explode(',', $participants_id));
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $conditions = [];
- foreach ($participants_id as $id) {
- $conditions[] = $wpdb->prepare("FIND_IN_SET(%d, participant_ids)", $id);
- }
- $where_participants = implode(" OR ", $conditions);
+ $query = $wpdb->prepare("
+ SELECT * FROM $table
+ WHERE event_id = %d
+ AND (
+ user_id = %d
+ OR participant_ids LIKE %s
+ OR participant_ids LIKE %s
+ OR participant_ids LIKE %s
+ OR participant_ids = %s
+ )
+ ", $event_id, $user_id,
+ "%," . $user_id . ",%", // middle
+ $user_id . ",%", // beginning
+ "%," . $user_id, // end
+ $user_id); // only one participant
+
+ $meetings = $wpdb->get_results($query, ARRAY_A);
+
+ if (empty($meetings)) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'error',
+ 'message' => 'No meetings found.',
+ 'data' => null
+ ], 404);
+ }
- $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $sql = "
- SELECT * FROM $table
- WHERE event_id = %d
- AND (user_id = %d OR ($where_participants))
- ";
- $query = $wpdb->prepare($sql, $event_id, $user_id);
- $meetings = $wpdb->get_results($query, ARRAY_A);
-
- if (empty($meetings)) {
- return new WP_REST_Response(['code' => 404, 'status' => 'error', 'message' => 'No meetings found.', 'data' => null], 404);
- }
+ $meeting_data = [];
+ foreach ($meetings as $meeting) {
+ $participant_statuses = maybe_unserialize($meeting['participant_ids']);
+ if (!is_array($participant_statuses)) {
+ $participant_statuses = [];
+ }
- // Collect all user IDs involved
- $all_user_ids = [$user_id];
- foreach ($meetings as $meeting) {
- $all_user_ids = array_merge($all_user_ids, array_map('intval', explode(',', $meeting['participant_ids'])));
+ $participants_info = [];
+ foreach ($participant_statuses as $pid => $status) {
+ if ((int)$pid !== $user_id) {
+ $participants_info[] = [
+ 'id' => (int)$pid,
+ 'status' => (int)$status
+ ];
}
- $all_user_ids = array_unique($all_user_ids);
+ }
- $profiles = $wpdb->get_results(
- $wpdb->prepare("SELECT user_id, profession, profile_photo FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id IN (" . implode(',', array_fill(0, count($all_user_ids), '%d')) . ")", ...$all_user_ids),
- ARRAY_A
- );
- $custom_user_indexed = array_column($profiles, null, 'user_id');
-
- $meeting_data = [];
- foreach ($meetings as $meeting) {
- $participant_array = maybe_unserialize($meeting['participant_ids']);
- $participants_info = [];
-
- if (is_array($participant_array)) {
- foreach ($participant_array as $pid => $status) {
- if ((int)$pid !== $user_id) {
- $participants_info[] = [
- 'id' => (int)$pid,
- 'status' => (int)$status,
- ];
- }
- }
- }
+ $meeting_data[] = [
+ 'meeting_id' => (int)$meeting['id'],
+ 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
+ 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
+ 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
+ 'message' => $meeting['message'],
+ 'host' => (int)$meeting['user_id'],
+ 'participants' => $participants_info,
+ ];
+ }
- $meeting_data[] = [
- 'meeting_id' => (int)$meeting['id'],
- 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
- 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
- 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
- 'message' => $meeting['message'],
- 'host' => (int)$meeting['user_id'],
- 'participants' => $participants_info,
- ];
- }
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meetings retrieved successfully.',
+ 'data' => $meeting_data
+ ], 200);
+ }
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Meetings retrieved successfully.',
- 'data' => $meeting_data,
- ], 200);
- }
public function cancel_meeting(WP_REST_Request $request) {
global $wpdb;
From 3a96b8291574a0929d083f092f1e1ddfd0cf0a60 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 17 Jun 2025 15:48:45 +0530
Subject: [PATCH 061/171] #145 Change date format
---
includes/wpem-rest-matchmaking-user-messages.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 3571a16..9eb8076 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -317,7 +317,7 @@ public function handle_get_conversation_list($request) {
'profession' => $wpdb->get_var($wpdb->prepare("SELECT profession FROM $profile_tbl WHERE user_id = %d", $uid)),
'company_name' => $wpdb->get_var($wpdb->prepare("SELECT company_name FROM $profile_tbl WHERE user_id = %d", $uid)),
'last_message' => $last_message_row ? $last_message_row->message : null,
- 'message_time' => $last_message_row ? date('d/m/y, h:i A', strtotime($last_message_row->created_at)) : null,
+ 'message_time' => $last_message_row ? date('Y-m-d H:i:s', strtotime($last_message_row->created_at)) : null,
];
}
From 7d2f60382e1e50ac66520a6883e8c1c4d217a141 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 19 Jun 2025 16:46:52 +0530
Subject: [PATCH 062/171] #145 accept decline meeting api
---
.../wpem-rest-matchmaking-create-meetings.php | 132 +++++++++++++++---
1 file changed, 110 insertions(+), 22 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 894d828..c257aba 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -32,6 +32,7 @@ public function register_routes() {
'callback' => [$this, 'get_user_meetings'],
'permission_callback' => [$auth_controller, 'check_authentication'],
]);
+
register_rest_route($this->namespace, '/cancel-meeting', [
'methods' => WP_REST_Server::CREATABLE,
'callback' => [$this, 'cancel_meeting'],
@@ -41,6 +42,18 @@ public function register_routes() {
'user_id' => ['required' => true, 'type' => 'integer'],
],
]);
+
+ register_rest_route($this->namespace, '/update-meeting-status', [
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => [$this, 'update_meeting_status'],
+ 'permission_callback' => [$auth_controller, 'check_authentication'],
+ 'args' => [
+ 'meeting_id' => ['required' => true, 'type' => 'integer'],
+ 'user_id' => ['required' => true, 'type' => 'integer'],
+ 'status' => ['required' => true, 'type' => 'integer', 'enum' => [0, 1]],
+ ],
+ ]);
+
}
public function create_meeting(WP_REST_Request $request) {
@@ -69,7 +82,7 @@ public function create_meeting(WP_REST_Request $request) {
$inserted = $wpdb->insert($table, [
'user_id' => $user_id,
'event_id' => $event_id,
- 'participant_ids' => implode(',', $participants),
+ 'participant_ids' => serialize($participants),
'meeting_date' => $meeting_date,
'meeting_start_time' => $start_time,
'meeting_end_time' => $end_time,
@@ -218,29 +231,43 @@ public function get_user_meetings(WP_REST_Request $request) {
$meeting_data = [];
foreach ($meetings as $meeting) {
$participant_statuses = maybe_unserialize($meeting['participant_ids']);
- if (!is_array($participant_statuses)) {
- $participant_statuses = [];
- }
+ if (!is_array($participant_statuses)) {
+ $participant_statuses = [];
+ }
- $participants_info = [];
- foreach ($participant_statuses as $pid => $status) {
- if ((int)$pid !== $user_id) {
- $participants_info[] = [
- 'id' => (int)$pid,
- 'status' => (int)$status
- ];
- }
- }
+ $participants_info = [];
+ foreach ($participant_statuses as $pid => $status) {
+ if ((int)$pid === $user_id) continue;
+
+ // Get user display name
+ $user_data = get_userdata($pid);
+ $display_name = $user_data ? $user_data->display_name : '';
+
+ // Get extra profile info from custom table
+ $meta = $wpdb->get_row($wpdb->prepare(
+ "SELECT profile_photo, profession, company_name FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d",
+ $pid
+ ));
+
+ $participants_info[] = [
+ 'id' => (int)$pid,
+ 'status' => (int)$status,
+ 'name' => $display_name,
+ 'image' => !empty($meta->profile_photo) ? esc_url($meta->profile_photo) : '',
+ 'profession' => isset($meta->profession) ? esc_html($meta->profession) : '',
+ 'company' => isset($meta->company_name) ? esc_html($meta->company_name) : '',
+ ];
+ }
- $meeting_data[] = [
- 'meeting_id' => (int)$meeting['id'],
- 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
- 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
- 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
- 'message' => $meeting['message'],
- 'host' => (int)$meeting['user_id'],
- 'participants' => $participants_info,
- ];
+ $meeting_data[] = [
+ 'meeting_id' => (int)$meeting['id'],
+ 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
+ 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
+ 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
+ 'message' => $meeting['message'],
+ 'host' => (int)$meeting['user_id'],
+ 'participants' => $participants_info,
+ ];
}
return new WP_REST_Response([
@@ -316,6 +343,67 @@ public function cancel_meeting(WP_REST_Request $request) {
'data' => ['meeting_id' => $meeting_id],
], 200);
}
+ public function update_meeting_status(WP_REST_Request $request) {
+ global $wpdb;
+
+ $meeting_id = intval($request->get_param('meeting_id'));
+ $user_id = intval($request->get_param('user_id'));
+ $new_status = intval($request->get_param('status'));
+
+ if (!$meeting_id || !$user_id || !in_array($new_status, [0, 1], true)) {
+ return new WP_REST_Response(['code' => 400, 'message' => 'Invalid parameters.'], 400);
+ }
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $meeting = $wpdb->get_row($wpdb->prepare("SELECT participant_ids FROM $table WHERE id = %d", $meeting_id));
+
+ if (!$meeting) {
+ return new WP_REST_Response(['code' => 404, 'message' => 'Meeting not found.'], 404);
+ }
+
+ $participant_data = maybe_unserialize($meeting->participant_ids);
+ if (!is_array($participant_data)) {
+ $participant_data = [];
+ }
+
+ if (!array_key_exists($user_id, $participant_data)) {
+ return new WP_REST_Response(['code' => 403, 'message' => 'You are not a participant of this meeting.'], 403);
+ }
+
+ // Update current user's status
+ $participant_data[$user_id] = $new_status;
+
+ // If at least one participant has accepted (status = 1), mark meeting as accepted
+ $meeting_status = (in_array(1, $participant_data, true)) ? 1 : 0;
+
+ // Update in DB
+ $updated = $wpdb->update(
+ $table,
+ [
+ 'participant_ids' => maybe_serialize($participant_data),
+ 'meeting_status' => $meeting_status,
+ ],
+ ['id' => $meeting_id],
+ ['%s', '%d'],
+ ['%d']
+ );
+
+ if ($updated === false) {
+ return new WP_REST_Response(['code' => 500, 'message' => 'Failed to update status.'], 500);
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => $new_status ? 'Meeting accepted.' : 'Meeting declined.',
+ 'data' => [
+ 'meeting_id' => $meeting_id,
+ 'participant_id' => $user_id,
+ 'participant_status' => $new_status,
+ 'meeting_status' => $meeting_status,
+ ]
+ ], 200);
+ }
}
new WPEM_REST_Create_Meeting_Controller();
From 86d92037c8fff6737c7711978aa57fdc02b60e41 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 20 Jun 2025 11:54:20 +0530
Subject: [PATCH 063/171] #145
---
includes/wpem-rest-matchmaking-create-meetings.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index c257aba..fae6fae 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -77,6 +77,7 @@ public function create_meeting(WP_REST_Request $request) {
// Filter out the user themselves from participant list
$participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
+ $participants = array_fill_keys($participants, 0);
$table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
$inserted = $wpdb->insert($table, [
From 8d3037d98c868f412a31d38fdcd03073fa18a2fe Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 20 Jun 2025 17:42:18 +0530
Subject: [PATCH 064/171] #145
---
includes/wpem-rest-matchmaking-create-meetings.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index fae6fae..dc9b35c 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -268,6 +268,7 @@ public function get_user_meetings(WP_REST_Request $request) {
'message' => $meeting['message'],
'host' => (int)$meeting['user_id'],
'participants' => $participants_info,
+ 'meeting_status'=> $meeting['meeting_status']
];
}
From 5462e59569af2a9e51299578f463a1a9ddf54bf0 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 20 Jun 2025 18:52:44 +0530
Subject: [PATCH 065/171] #145
---
.../wpem-rest-matchmaking-create-meetings.php | 62 +++++++++----------
1 file changed, 30 insertions(+), 32 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index dc9b35c..759b182 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -176,7 +176,7 @@ public function create_meeting(WP_REST_Request $request) {
], 200);
}
- public function get_user_meetings(WP_REST_Request $request) {
+ public function get_user_meetings(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
'code' => 403,
@@ -202,49 +202,38 @@ public function get_user_meetings(WP_REST_Request $request) {
$table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $query = $wpdb->prepare("
- SELECT * FROM $table
- WHERE event_id = %d
- AND (
- user_id = %d
- OR participant_ids LIKE %s
- OR participant_ids LIKE %s
- OR participant_ids LIKE %s
- OR participant_ids = %s
- )
- ", $event_id, $user_id,
- "%," . $user_id . ",%", // middle
- $user_id . ",%", // beginning
- "%," . $user_id, // end
- $user_id); // only one participant
-
- $meetings = $wpdb->get_results($query, ARRAY_A);
-
- if (empty($meetings)) {
+ // Fetch ALL meetings for this event
+ $all_meetings = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table WHERE event_id = %d", $event_id), ARRAY_A);
+
+ if (empty($all_meetings)) {
return new WP_REST_Response([
'code' => 404,
'status' => 'error',
- 'message' => 'No meetings found.',
+ 'message' => 'No meetings found for this event.',
'data' => null
], 404);
}
$meeting_data = [];
- foreach ($meetings as $meeting) {
+
+ foreach ($all_meetings as $meeting) {
$participant_statuses = maybe_unserialize($meeting['participant_ids']);
if (!is_array($participant_statuses)) {
$participant_statuses = [];
}
+ // Check if current user is host or in participant list
+ if ((int)$meeting['user_id'] !== $user_id && !array_key_exists($user_id, $participant_statuses)) {
+ continue;
+ }
+
$participants_info = [];
foreach ($participant_statuses as $pid => $status) {
if ((int)$pid === $user_id) continue;
- // Get user display name
$user_data = get_userdata($pid);
$display_name = $user_data ? $user_data->display_name : '';
- // Get extra profile info from custom table
$meta = $wpdb->get_row($wpdb->prepare(
"SELECT profile_photo, profession, company_name FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d",
$pid
@@ -261,17 +250,26 @@ public function get_user_meetings(WP_REST_Request $request) {
}
$meeting_data[] = [
- 'meeting_id' => (int)$meeting['id'],
- 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
- 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
- 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
- 'message' => $meeting['message'],
- 'host' => (int)$meeting['user_id'],
- 'participants' => $participants_info,
- 'meeting_status'=> $meeting['meeting_status']
+ 'meeting_id' => (int)$meeting['id'],
+ 'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
+ 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
+ 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
+ 'message' => $meeting['message'],
+ 'host' => (int)$meeting['user_id'],
+ 'participants' => $participants_info,
+ 'meeting_status' => (int)$meeting['meeting_status']
];
}
+ if (empty($meeting_data)) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'error',
+ 'message' => 'No meetings found for this user.',
+ 'data' => null
+ ], 404);
+ }
+
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
From b885bf0f494b6bda7d5bb4b50b72b84ee737df0f Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 24 Jun 2025 12:27:23 +0530
Subject: [PATCH 066/171] #145
---
includes/wpem-rest-matchmaking-create-meetings.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 759b182..806109e 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -77,7 +77,7 @@ public function create_meeting(WP_REST_Request $request) {
// Filter out the user themselves from participant list
$participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
- $participants = array_fill_keys($participants, 0);
+ $participants = array_fill_keys($participants, -1);
$table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
$inserted = $wpdb->insert($table, [
From 8ec230a75fa935d232c114d2600372d7e5c082e3 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 26 Jun 2025 11:20:38 +0530
Subject: [PATCH 067/171] #145 APIs For Let's Meet Feature
---
.../wpem-rest-matchmaking-create-meetings.php | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 806109e..1408f29 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -248,14 +248,27 @@ public function get_user_meetings(WP_REST_Request $request) {
'company' => isset($meta->company_name) ? esc_html($meta->company_name) : '',
];
}
-
+ $host_id = (int)$meeting['user_id'];
+ $host_user = get_userdata($host_id);
+ $host_meta = $wpdb->get_row($wpdb->prepare(
+ "SELECT profile_photo, profession, company_name FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d",
+ $host_id
+ ));
+
+ $host_info = [
+ 'id' => $host_id,
+ 'name' => $host_user ? $host_user->display_name : '',
+ 'image' => !empty($host_meta->profile_photo) ? esc_url($host_meta->profile_photo) : '',
+ 'profession' => isset($host_meta->profession) ? esc_html($host_meta->profession) : '',
+ 'company' => isset($host_meta->company_name) ? esc_html($host_meta->company_name) : '',
+ ];
$meeting_data[] = [
'meeting_id' => (int)$meeting['id'],
'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
'message' => $meeting['message'],
- 'host' => (int)$meeting['user_id'],
+ 'host_info' => $host_info,
'participants' => $participants_info,
'meeting_status' => (int)$meeting['meeting_status']
];
From 40fc965acf5843b1e13910ddd5999be8fe249d2d Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 26 Jun 2025 14:53:56 +0530
Subject: [PATCH 068/171] #145
---
includes/wpem-rest-matchmaking-create-meetings.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 1408f29..8d40386 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -229,7 +229,7 @@ public function get_user_meetings(WP_REST_Request $request) {
$participants_info = [];
foreach ($participant_statuses as $pid => $status) {
- if ((int)$pid === $user_id) continue;
+ //if ((int)$pid === $user_id) continue;
$user_data = get_userdata($pid);
$display_name = $user_data ? $user_data->display_name : '';
From a1f86b84c1c3df3d867f4afa23392f33bf2279a0 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 1 Jul 2025 13:18:07 +0530
Subject: [PATCH 069/171] #176 Get User's booked meeting slots api
---
.../wpem-rest-matchmaking-create-meetings.php | 73 +++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 8d40386..01f8e20 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -53,6 +53,21 @@ public function register_routes() {
'status' => ['required' => true, 'type' => 'integer', 'enum' => [0, 1]],
],
]);
+ register_rest_route($this->namespace, '/get-availability-slots', [
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => [$this, 'get_booked_meeting_slots'],
+ 'permission_callback' => [$auth_controller, 'check_authentication'],
+ 'args' => [
+ 'event_id' => [
+ 'required' => true,
+ 'type' => 'integer'
+ ],
+ 'user_id' => [
+ 'required' => false,
+ 'type' => 'integer'
+ ]
+ ]
+ ]);
}
@@ -292,6 +307,14 @@ public function get_user_meetings(WP_REST_Request $request) {
}
public function cancel_meeting(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
global $wpdb;
$meeting_id = intval($request->get_param('meeting_id'));
@@ -357,6 +380,14 @@ public function cancel_meeting(WP_REST_Request $request) {
], 200);
}
public function update_meeting_status(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
global $wpdb;
$meeting_id = intval($request->get_param('meeting_id'));
@@ -417,6 +448,48 @@ public function update_meeting_status(WP_REST_Request $request) {
]
], 200);
}
+ public function get_booked_meeting_slots(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+ global $wpdb;
+
+ $event_id = intval($request->get_param('event_id'));
+ $user_id = intval($request->get_param('user_id')) ?: get_current_user_id();
+
+ if (!$event_id || !$user_id) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'error',
+ 'message' => 'Missing event_id or unauthorized access.',
+ 'data' => null
+ ], 400);
+ }
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $saved = $wpdb->get_var(
+ $wpdb->prepare("SELECT meeting_availability_slot FROM $table WHERE user_id = %d", $user_id)
+ );
+
+ $saved_data = !empty($saved) ? maybe_unserialize($saved) : [];
+
+ $event_slots = $saved_data[$event_id] ?? [];
+
+ if (is_array($event_slots)) {
+ ksort($event_slots); // sorts date keys in ascending order
+ }
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Availability slots fetched successfully.',
+ 'data' => $event_slots
+ ], 200);
+ }
}
new WPEM_REST_Create_Meeting_Controller();
From db1dd52ee9d002cdd8ed16c301275cdcb15ae6d5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 1 Jul 2025 16:09:09 +0530
Subject: [PATCH 070/171] #176
---
.../wpem-rest-matchmaking-create-meetings.php | 25 +++++++++++++------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 01f8e20..e7a45bf 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -457,6 +457,7 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
'data' => null
], 403);
}
+
global $wpdb;
$event_id = intval($request->get_param('event_id'));
@@ -472,22 +473,30 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
}
$table = $wpdb->prefix . 'wpem_matchmaking_users';
- $saved = $wpdb->get_var(
- $wpdb->prepare("SELECT meeting_availability_slot FROM $table WHERE user_id = %d", $user_id)
+
+ // Get availability slot and available flag in single query
+ $result = $wpdb->get_row(
+ $wpdb->prepare("SELECT meeting_availability_slot, available_for_meeting FROM $table WHERE user_id = %d", $user_id),
+ ARRAY_A
);
- $saved_data = !empty($saved) ? maybe_unserialize($saved) : [];
+ $saved_data = !empty($result['meeting_availability_slot']) ? maybe_unserialize($result['meeting_availability_slot']) : [];
+ $available_flag = isset($result['available_for_meeting']) ? (int)$result['available_for_meeting'] : 0;
$event_slots = $saved_data[$event_id] ?? [];
-
+
if (is_array($event_slots)) {
- ksort($event_slots); // sorts date keys in ascending order
+ ksort($event_slots); // sort by date keys
}
+
return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
+ 'code' => 200,
+ 'status' => 'OK',
'message' => 'Availability slots fetched successfully.',
- 'data' => $event_slots
+ 'data' => [
+ 'available_for_meeting' => $available_flag,
+ 'slots' => $event_slots
+ ]
], 200);
}
}
From e9c1ca25155a0925c4a4081c4bf18e89a0065bbe Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 2 Jul 2025 18:58:56 +0530
Subject: [PATCH 071/171] #176 Get common slot api
---
.../wpem-rest-matchmaking-create-meetings.php | 127 +++++++++++++++++-
1 file changed, 126 insertions(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index e7a45bf..78cc5f6 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -68,7 +68,25 @@ public function register_routes() {
]
]
]);
-
+ register_rest_route($this->namespace, '/common-availability-slots', [
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => [$this, 'get_common_availability_slots'],
+ 'permission_callback' => [$auth_controller, 'check_authentication'],
+ 'args' => [
+ 'event_id' => [
+ 'required' => true,
+ 'type' => 'integer',
+ ],
+ 'user_ids' => [
+ 'required' => true,
+ 'type' => 'array',
+ ],
+ 'date' => [
+ 'required' => true,
+ 'type' => 'string', // expected in Y-m-d format
+ ],
+ ]
+ ]);
}
public function create_meeting(WP_REST_Request $request) {
@@ -499,6 +517,113 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
]
], 200);
}
+ public function get_common_availability_slots($request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+ global $wpdb;
+
+ $event_id = intval($request->get_param('event_id'));
+ $user_ids = $request->get_param('user_ids');
+ $date = sanitize_text_field($request->get_param('date'));
+
+ if (!is_array($user_ids) || empty($user_ids) || !$event_id || !$date) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'ERROR',
+ 'message' => 'Invalid parameters.',
+ 'data' => [],
+ ], 400);
+ }
+
+ $placeholders = implode(',', array_fill(0, count($user_ids), '%d'));
+ $query = "
+ SELECT user_id, meeting_availability_slot
+ FROM {$wpdb->prefix}wpem_matchmaking_users
+ WHERE user_id IN ($placeholders)
+ ";
+ $prepared = $wpdb->prepare($query, $user_ids);
+ $results = $wpdb->get_results($prepared);
+
+ if (empty($results)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No common slots found.',
+ 'data' => ['common_slots' => []],
+ ]);
+ }
+
+ $all_user_slots = [];
+
+ foreach ($results as $row) {
+ $data = maybe_unserialize($row->meeting_availability_slot);
+
+ if (
+ empty($data) ||
+ !isset($data[$event_id]) ||
+ !isset($data[$event_id][$date]) ||
+ !is_array($data[$event_id][$date])
+ ) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No common slots found.',
+ 'data' => ['common_slots' => []],
+ ]);
+ }
+
+ $all_user_slots[] = $data[$event_id][$date];
+ }
+
+ // If only one user, just return their slots
+ if (count($all_user_slots) === 1) {
+ sort($all_user_slots[0]);
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Availability slots retrieved successfully.',
+ 'data' => [
+ 'event_id' => $event_id,
+ 'date' => $date,
+ 'common_slots' => array_values($all_user_slots[0]),
+ ],
+ ]);
+ }
+
+ // Multiple users: get intersection
+ $common_slots = array_shift($all_user_slots);
+ foreach ($all_user_slots as $slots) {
+ $common_slots = array_intersect($common_slots, $slots);
+ }
+
+ sort($common_slots);
+
+ if (empty($common_slots)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No common slots found.',
+ 'data' => ['common_slots' => []],
+ ]);
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Common availability slots retrieved successfully.',
+ 'data' => [
+ 'event_id' => $event_id,
+ 'date' => $date,
+ 'common_slots' => array_values($common_slots),
+ ],
+ ]);
+ }
}
new WPEM_REST_Create_Meeting_Controller();
From fa177f1db503fe53279c371d396054c8e6e304dd Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 3 Jul 2025 11:56:06 +0530
Subject: [PATCH 072/171] #176 Update user's meeting availability api
---
.../wpem-rest-matchmaking-create-meetings.php | 87 +++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 78cc5f6..89e2364 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -68,6 +68,29 @@ public function register_routes() {
]
]
]);
+ register_rest_route($this->namespace, '/update-availability-slots', [
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => [$this, 'update_availability_slots_rest'],
+ 'permission_callback' => [$auth_controller, 'check_authentication'],
+ 'args' => [
+ 'event_id' => [
+ 'required' => true,
+ 'type' => 'integer'
+ ],
+ 'availability_slots' => [
+ 'required' => true,
+ 'type' => 'object'
+ ],
+ 'available_for_meeting' => [
+ 'required' => false,
+ 'type' => 'boolean'
+ ],
+ 'user_id' => [
+ 'required' => false,
+ 'type' => 'integer'
+ ]
+ ]
+ ]);
register_rest_route($this->namespace, '/common-availability-slots', [
'methods' => WP_REST_Server::CREATABLE,
'callback' => [$this, 'get_common_availability_slots'],
@@ -517,6 +540,70 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
]
], 200);
}
+ public function update_availability_slots_rest(WP_REST_Request $request) {
+ global $wpdb;
+ $table = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ $event_id = $request->get_param('event_id');
+ $availability_slots = $request->get_param('availability_slots');
+ $available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
+ $user_id = $request->get_param('user_id') ?: get_current_user_id();
+
+ if (!$user_id || !$event_id || !is_array($availability_slots)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'ERROR',
+ 'message' => 'Missing or invalid parameters.'
+ ], 400);
+ }
+
+ // Get existing availability
+ $current_data = $wpdb->get_var($wpdb->prepare(
+ "SELECT meeting_availability_slot FROM {$table} WHERE user_id = %d",
+ $user_id
+ ));
+
+ $availability_data = [];
+ if ($current_data) {
+ $maybe_unserialized = maybe_unserialize($current_data);
+ if (is_array($maybe_unserialized)) {
+ $availability_data = $maybe_unserialized;
+ }
+ }
+
+ if (!isset($availability_data[$event_id]) || !is_array($availability_data[$event_id])) {
+ $availability_data[$event_id] = [];
+ }
+
+ foreach ($availability_slots as $date => $slots) {
+ $availability_data[$event_id][$date] = $slots;
+ }
+
+ $updated = $wpdb->update(
+ $table,
+ [
+ 'meeting_availability_slot' => maybe_serialize($availability_data),
+ 'available_for_meeting' => $available_for_meeting,
+ ],
+ ['user_id' => $user_id],
+ ['%s', '%d'],
+ ['%d']
+ );
+
+ if ($updated !== false) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Availability updated successfully.',
+ ], 200);
+ } else {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'ERROR',
+ 'message' => 'No changes made or failed to save availability.',
+ ], 500);
+ }
+ }
public function get_common_availability_slots($request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
From f269bed5a360cba1d69f414557ad7abe190cd127 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 3 Jul 2025 12:14:42 +0530
Subject: [PATCH 073/171] #176
---
includes/wpem-rest-matchmaking-filter-users.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index fa495a7..142aca8 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -104,7 +104,6 @@ public function handle_your_matches($request) {
$search_like = '%' . $wpdb->esc_like($search) . '%';
$search_conditions = [
- "about LIKE %s",
"city LIKE %s",
"country LIKE %s",
"profession LIKE %s",
From 1704066cab3a4fe4b811acb4aa3723aa97c5d2f5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 4 Jul 2025 14:59:38 +0530
Subject: [PATCH 074/171] #176 Changes for booked and available for meeting
---
.../wpem-rest-matchmaking-create-meetings.php | 69 ++++++++++++-------
1 file changed, 43 insertions(+), 26 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 89e2364..7b6340c 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -544,10 +544,10 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
global $wpdb;
$table = $wpdb->prefix . 'wpem_matchmaking_users';
- $event_id = $request->get_param('event_id');
- $availability_slots = $request->get_param('availability_slots');
+ $event_id = intval($request->get_param('event_id'));
+ $availability_slots = $request->get_param('availability_slots'); // Expected as [ '2024-07-05' => ['08:00', '09:00'] ]
$available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
- $user_id = $request->get_param('user_id') ?: get_current_user_id();
+ $user_id = intval($request->get_param('user_id') ?: get_current_user_id());
if (!$user_id || !$event_id || !is_array($availability_slots)) {
return new WP_REST_Response([
@@ -571,12 +571,29 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
}
}
+ // Ensure event array is initialized
if (!isset($availability_data[$event_id]) || !is_array($availability_data[$event_id])) {
$availability_data[$event_id] = [];
}
- foreach ($availability_slots as $date => $slots) {
- $availability_data[$event_id][$date] = $slots;
+ // Merge submitted availability into existing structure, preserving flags
+ foreach ($availability_slots as $date => $new_slots) {
+ if (!isset($availability_data[$event_id][$date]) || !is_array($availability_data[$event_id][$date])) {
+ $availability_data[$event_id][$date] = [];
+ }
+
+ $existing_slots = $availability_data[$event_id][$date];
+ $updated_slots = [];
+
+ foreach ($new_slots as $slot) {
+ if (isset($existing_slots[$slot]) && $existing_slots[$slot] === 1) {
+ $updated_slots[$slot] = 1; // Preserve booking flag
+ } else {
+ $updated_slots[$slot] = 0; // Mark as available
+ }
+ }
+
+ $availability_data[$event_id][$date] = $updated_slots;
}
$updated = $wpdb->update(
@@ -604,15 +621,10 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
], 500);
}
}
+
+
+
public function get_common_availability_slots($request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
global $wpdb;
$event_id = intval($request->get_param('event_id'));
@@ -665,10 +677,24 @@ public function get_common_availability_slots($request) {
]);
}
- $all_user_slots[] = $data[$event_id][$date];
+ // Filter only available slots (value === 0)
+ $available_slots = array_keys(array_filter($data[$event_id][$date], function($v) {
+ return $v === 0;
+ }));
+
+ if (empty($available_slots)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No common slots found.',
+ 'data' => ['common_slots' => []],
+ ]);
+ }
+
+ $all_user_slots[] = $available_slots;
}
- // If only one user, just return their slots
+ // Only one user: return their available slots
if (count($all_user_slots) === 1) {
sort($all_user_slots[0]);
return new WP_REST_Response([
@@ -683,7 +709,7 @@ public function get_common_availability_slots($request) {
]);
}
- // Multiple users: get intersection
+ // Multiple users: intersect available time slots
$common_slots = array_shift($all_user_slots);
foreach ($all_user_slots as $slots) {
$common_slots = array_intersect($common_slots, $slots);
@@ -691,19 +717,10 @@ public function get_common_availability_slots($request) {
sort($common_slots);
- if (empty($common_slots)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No common slots found.',
- 'data' => ['common_slots' => []],
- ]);
- }
-
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
- 'message' => 'Common availability slots retrieved successfully.',
+ 'message' => empty($common_slots) ? 'No common slots found.' : 'Common availability slots retrieved successfully.',
'data' => [
'event_id' => $event_id,
'date' => $date,
From 6e802686dace7dc54c0f02a5525edb75ec41ae73 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Sun, 6 Jul 2025 12:16:50 +0530
Subject: [PATCH 075/171] #176
---
.../wpem-rest-matchmaking-create-meetings.php | 52 +++++++++++--------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 7b6340c..aa51a2f 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -545,11 +545,11 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
$table = $wpdb->prefix . 'wpem_matchmaking_users';
$event_id = intval($request->get_param('event_id'));
- $availability_slots = $request->get_param('availability_slots'); // Expected as [ '2024-07-05' => ['08:00', '09:00'] ]
+ $submitted_slots = $request->get_param('availability_slots'); // e.g., [ '2025-07-01' => ['08:00', '09:00'] ]
$available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
$user_id = intval($request->get_param('user_id') ?: get_current_user_id());
- if (!$user_id || !$event_id || !is_array($availability_slots)) {
+ if (!$user_id || !$event_id || !is_array($submitted_slots)) {
return new WP_REST_Response([
'code' => 400,
'status' => 'ERROR',
@@ -557,43 +557,52 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
], 400);
}
- // Get existing availability
$current_data = $wpdb->get_var($wpdb->prepare(
"SELECT meeting_availability_slot FROM {$table} WHERE user_id = %d",
$user_id
));
$availability_data = [];
- if ($current_data) {
+ if (!empty($current_data)) {
$maybe_unserialized = maybe_unserialize($current_data);
if (is_array($maybe_unserialized)) {
$availability_data = $maybe_unserialized;
}
}
- // Ensure event array is initialized
+ // Define full-day time slots (07:00 to 18:00)
+ $full_day_slots = [];
+ for ($h = 7; $h <= 18; $h++) {
+ $full_day_slots[] = str_pad($h, 2, '0', STR_PAD_LEFT) . ':00';
+ }
+
+ // Ensure structure exists
if (!isset($availability_data[$event_id]) || !is_array($availability_data[$event_id])) {
$availability_data[$event_id] = [];
}
- // Merge submitted availability into existing structure, preserving flags
- foreach ($availability_slots as $date => $new_slots) {
- if (!isset($availability_data[$event_id][$date]) || !is_array($availability_data[$event_id][$date])) {
+ foreach ($submitted_slots as $date => $selected_times) {
+ if (!isset($availability_data[$event_id][$date])) {
$availability_data[$event_id][$date] = [];
}
- $existing_slots = $availability_data[$event_id][$date];
- $updated_slots = [];
+ foreach ($full_day_slots as $slot) {
+ $existing_val = $availability_data[$event_id][$date][$slot] ?? null;
- foreach ($new_slots as $slot) {
- if (isset($existing_slots[$slot]) && $existing_slots[$slot] === 1) {
- $updated_slots[$slot] = 1; // Preserve booking flag
+ if (in_array($slot, $selected_times)) {
+ // If selected in request, mark 1
+ $availability_data[$event_id][$date][$slot] = 1;
} else {
- $updated_slots[$slot] = 0; // Mark as available
+ // Not selected
+ if ($existing_val === 1 || $existing_val === 2) {
+ // Keep existing value (already booked/available)
+ $availability_data[$event_id][$date][$slot] = $existing_val;
+ } else {
+ // Mark as unavailable
+ $availability_data[$event_id][$date][$slot] = 0;
+ }
}
}
-
- $availability_data[$event_id][$date] = $updated_slots;
}
$updated = $wpdb->update(
@@ -611,19 +620,16 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
- 'message' => 'Availability updated successfully.',
+ 'message' => 'Availability updated successfully.'
], 200);
} else {
return new WP_REST_Response([
'code' => 500,
'status' => 'ERROR',
- 'message' => 'No changes made or failed to save availability.',
+ 'message' => 'Failed to update availability.'
], 500);
}
}
-
-
-
public function get_common_availability_slots($request) {
global $wpdb;
@@ -677,9 +683,9 @@ public function get_common_availability_slots($request) {
]);
}
- // Filter only available slots (value === 0)
+ // Filter only available slots (value === 1)
$available_slots = array_keys(array_filter($data[$event_id][$date], function($v) {
- return $v === 0;
+ return $v === 1;
}));
if (empty($available_slots)) {
From 7b4d0448be68cf1a7f7baf446133262c06e88e70 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 7 Jul 2025 09:19:12 +0530
Subject: [PATCH 076/171] #176 APIs For availability of meeting slots
---
.../wpem-rest-matchmaking-create-meetings.php | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index aa51a2f..831344e 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -217,7 +217,41 @@ public function create_meeting(WP_REST_Request $request) {
",
['Content-Type: text/html; charset=UTF-8']
);
+ // Update booked slot (2) for all participants and host
+ $availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $all_user_ids = array_merge([ $user_id ], array_keys($participants)); // host + participant IDs
+
+ foreach ($all_user_ids as $uid) {
+ $serialized = $wpdb->get_var($wpdb->prepare(
+ "SELECT meeting_availability_slot FROM $availability_table WHERE user_id = %d",
+ $uid
+ ));
+
+ $slot_data = maybe_unserialize($serialized);
+ if (!is_array($slot_data)) {
+ $slot_data = [];
+ }
+ // Ensure keys exist
+ if (!isset($slot_data[$event_id])) {
+ $slot_data[$event_id] = [];
+ }
+ if (!isset($slot_data[$event_id][$meeting_date])) {
+ $slot_data[$event_id][$meeting_date] = [];
+ }
+
+ // Mark the start_time slot as booked (2)
+ $slot_data[$event_id][$meeting_date][$start_time] = 2;
+
+ // Update in DB
+ $wpdb->update(
+ $availability_table,
+ ['meeting_availability_slot' => maybe_serialize($slot_data)],
+ ['user_id' => $uid],
+ ['%s'],
+ ['%d']
+ );
+ }
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
From a0450b2fef02b8879d120e77120124213e9e5c44 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 7 Jul 2025 11:38:36 +0530
Subject: [PATCH 077/171] #176 Update availability slot status when meeting
cancelled
---
.../wpem-rest-matchmaking-create-meetings.php | 50 ++++++++++++++++---
1 file changed, 43 insertions(+), 7 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 831344e..e50df2e 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -380,7 +380,6 @@ public function get_user_meetings(WP_REST_Request $request) {
'data' => $meeting_data
], 200);
}
-
public function cancel_meeting(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
@@ -390,6 +389,7 @@ public function cancel_meeting(WP_REST_Request $request) {
'data' => null
], 403);
}
+
global $wpdb;
$meeting_id = intval($request->get_param('meeting_id'));
@@ -416,20 +416,56 @@ public function cancel_meeting(WP_REST_Request $request) {
return new WP_REST_Response(['code' => 500, 'status' => 'error', 'message' => 'Failed to cancel meeting.'], 500);
}
- // Notify participants
+ // Participant + host IDs
$participant_ids = maybe_unserialize($meeting['participant_ids']);
- if (!is_array($participant_ids)) {
- $participant_ids = [];
+ if (!is_array($participant_ids)) $participant_ids = [];
+ $participant_ids = array_keys($participant_ids);
+ $participant_ids[] = (int)$meeting['user_id'];
+ $participant_ids = array_unique($participant_ids);
+
+ // === Availability reset ===
+ $event_id = (int)$meeting['event_id'];
+ $meeting_date = $meeting['meeting_date'];
+ $start_time = date('H:i', strtotime($meeting['meeting_start_time'])); // convert from H:i:s to H:i
+
+ $profile_table = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ foreach ($participant_ids as $pid) {
+ $current_slots_serialized = $wpdb->get_var($wpdb->prepare(
+ "SELECT meeting_availability_slot FROM $profile_table WHERE user_id = %d",
+ $pid
+ ));
+
+ $current_slots = maybe_unserialize($current_slots_serialized);
+ if (!is_array($current_slots)) $current_slots = [];
+
+ if (!isset($current_slots[$event_id])) $current_slots[$event_id] = [];
+ if (!isset($current_slots[$event_id][$meeting_date])) $current_slots[$event_id][$meeting_date] = [];
+
+ if (isset($current_slots[$event_id][$meeting_date][$start_time]) && $current_slots[$event_id][$meeting_date][$start_time] == 2) {
+ $current_slots[$event_id][$meeting_date][$start_time] = 1;
+
+ $wpdb->update(
+ $profile_table,
+ ['meeting_availability_slot' => maybe_serialize($current_slots)],
+ ['user_id' => $pid],
+ ['%s'],
+ ['%d']
+ );
+ }
}
- foreach ($participant_ids as $pid => $status) {
+ // Notify participants
+ foreach ($participant_ids as $pid) {
+ if ($pid == $user_id) continue;
+
$user = get_userdata($pid);
if ($user) {
wp_mail(
$user->user_email,
'Meeting Cancelled',
"Hello {$user->display_name},
- The meeting scheduled on {$meeting['meeting_date']} has been cancelled .
",
+ The meeting scheduled on {$meeting_date} has been cancelled .
",
['Content-Type: text/html; charset=UTF-8']
);
}
@@ -442,7 +478,7 @@ public function cancel_meeting(WP_REST_Request $request) {
$host->user_email,
'You Cancelled a Meeting',
"Hello {$host->display_name},
- You have cancelled the meeting scheduled on {$meeting['meeting_date']} .
",
+ You have cancelled the meeting scheduled on {$meeting_date} .
",
['Content-Type: text/html; charset=UTF-8']
);
}
From d2d5a2f4e125da53f85ceea4a93bb96f77ca3836 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 7 Jul 2025 14:56:34 +0530
Subject: [PATCH 078/171] #176
---
.../wpem-rest-matchmaking-create-meetings.php | 34 +++++--------------
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index e50df2e..021826f 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -615,7 +615,7 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
$table = $wpdb->prefix . 'wpem_matchmaking_users';
$event_id = intval($request->get_param('event_id'));
- $submitted_slots = $request->get_param('availability_slots'); // e.g., [ '2025-07-01' => ['08:00', '09:00'] ]
+ $submitted_slots = $request->get_param('availability_slots'); // Now: [ '2025-07-07' => [ '07:00' => 0 ] ]
$available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
$user_id = intval($request->get_param('user_id') ?: get_current_user_id());
@@ -640,37 +640,21 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
}
}
- // Define full-day time slots (07:00 to 18:00)
- $full_day_slots = [];
- for ($h = 7; $h <= 18; $h++) {
- $full_day_slots[] = str_pad($h, 2, '0', STR_PAD_LEFT) . ':00';
- }
-
- // Ensure structure exists
- if (!isset($availability_data[$event_id]) || !is_array($availability_data[$event_id])) {
+ // Ensure event structure exists
+ if (!isset($availability_data[$event_id])) {
$availability_data[$event_id] = [];
}
- foreach ($submitted_slots as $date => $selected_times) {
+ // Update the passed slots directly
+ foreach ($submitted_slots as $date => $slots) {
if (!isset($availability_data[$event_id][$date])) {
$availability_data[$event_id][$date] = [];
}
- foreach ($full_day_slots as $slot) {
- $existing_val = $availability_data[$event_id][$date][$slot] ?? null;
-
- if (in_array($slot, $selected_times)) {
- // If selected in request, mark 1
- $availability_data[$event_id][$date][$slot] = 1;
- } else {
- // Not selected
- if ($existing_val === 1 || $existing_val === 2) {
- // Keep existing value (already booked/available)
- $availability_data[$event_id][$date][$slot] = $existing_val;
- } else {
- // Mark as unavailable
- $availability_data[$event_id][$date][$slot] = 0;
- }
+ foreach ($slots as $time => $value) {
+ // Accept only 0, 1, or 2 as valid values
+ if (in_array($value, [0, 1, 2], true)) {
+ $availability_data[$event_id][$date][$time] = $value;
}
}
}
From c7e97ed06c5818b35b183ad3fdab2e50fb050931 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 8 Jul 2025 14:55:15 +0530
Subject: [PATCH 079/171] #176 Added new parameter in Create meeting api
---
.../wpem-rest-matchmaking-create-meetings.php | 260 +++++++++---------
1 file changed, 136 insertions(+), 124 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 021826f..b1353c4 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -20,8 +20,7 @@ public function register_routes() {
'user_id' => ['required' => true, 'type' => 'integer'],
'event_id' => ['required' => true, 'type' => 'integer'],
'meeting_date' => ['required' => true, 'type' => 'string'],
- 'meeting_start_time' => ['required' => true, 'type' => 'string'],
- 'meeting_end_time' => ['required' => true, 'type' => 'string'],
+ 'slot' => ['required' => true, 'type' => 'string'],
'meeting_participants' => ['required' => true, 'type' => 'array'],
'write_a_message' => ['required' => false, 'type' => 'string'],
],
@@ -111,112 +110,129 @@ public function register_routes() {
]
]);
}
+ public function create_meeting(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+
+ global $wpdb;
+
+ $user_id = intval($request->get_param('user_id'));
+ $event_id = intval($request->get_param('event_id'));
+ $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
+ $slot = sanitize_text_field($request->get_param('slot'));
+ $participants = $request->get_param('meeting_participants');
+ $message = sanitize_textarea_field($request->get_param('write_a_message'));
+
+ if (
+ !$user_id || !get_userdata($user_id) ||
+ empty($meeting_date) || empty($slot) ||
+ empty($participants) || !is_array($participants)
+ ) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'Missing or invalid parameters.',
+ 'data' => []
+ ], 400);
+ }
+
+ // Filter out the user themselves from participant list
+ $participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
+ $participants = array_fill_keys($participants, -1); // -1 = pending
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $inserted = $wpdb->insert($table, [
+ 'user_id' => $user_id,
+ 'event_id' => $event_id,
+ 'participant_ids' => serialize($participants),
+ 'meeting_date' => $meeting_date,
+ 'meeting_start_time' => $slot,
+ 'meeting_end_time' => date("H:i", strtotime($slot . " +1 hour")),
+ 'message' => $message,
+ 'meeting_status' => 0
+ ], ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']);
+
+ if (!$inserted) {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Internal Server Error',
+ 'message' => 'Could not create meeting.',
+ 'data' => []
+ ], 500);
+ }
+
+ $meeting_id = $wpdb->insert_id;
+ $formatted_date = date("l, d F Y", strtotime($meeting_date));
+ $formatted_time = date("h:i A", strtotime($slot));
+ $sender_user = get_userdata($user_id);
+
+ $participant_details = [];
+
+ if (!empty($participants)) {
+ $profile_table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $placeholders = implode(',', array_fill(0, count($participants), '%d'));
+ $query = $wpdb->prepare("SELECT * FROM $profile_table WHERE user_id IN ($placeholders)", ...array_keys($participants));
+ $results = $wpdb->get_results($query, ARRAY_A);
+
+ foreach ($results as $participant) {
+ $participant_user = get_userdata($participant['user_id']);
+ $participant_name = $participant_user->display_name ?? 'User';
+ $participant_email = $participant_user->user_email ?? '';
+ $profile_picture = $participant['profile_photo'] ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
+
+ $participant_details[] = [
+ 'name' => $participant_name,
+ 'profession' => $participant['profession'] ?? '',
+ 'profile_picture' => esc_url($profile_picture)
+ ];
+
+ // Email to participant
+ $host_profile = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d", $user_id), ARRAY_A);
+ $host_company = $host_profile['company_name'] ?? '';
+ $host_city = $host_profile['city'] ?? '';
+ $all_countries = wpem_registration_get_all_countries();
+ $host_country = $all_countries[$host_profile['country']] ?? '';
+ $event_name = get_the_title($event_id) ?: '';
+ $timezone_abbr = wp_timezone_string();
+
+ $subject = "{$sender_user->display_name} requested a meeting with you";
+ $body = "
+ Hello {$participant_name},
+ {$sender_user->display_name} has requested a meeting with you.
+ Event: {$event_name}
+ Date: {$formatted_date}
+ Time: {$formatted_time} {$timezone_abbr}
+ Company: {$host_company}
+ City: {$host_city}
+ Country: {$host_country}
+ Message: {$message}
+ ";
+
+ wp_mail($participant_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
+ }
+ }
+
+ // Email to sender
+ $participant_names = implode(', ', array_column($participant_details, 'name'));
+ wp_mail(
+ $sender_user->user_email,
+ 'Your Meeting Request Has Been Sent',
+ "
+ Hello {$sender_user->display_name},
+ Your meeting request has been sent to: {$participant_names} .
+ Date: {$formatted_date}
+ Time: {$formatted_time}
+ Message: {$message}
+ ",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
- public function create_meeting(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response(['code' => 403, 'status' => 'Disabled', 'message' => 'Matchmaking functionality is not enabled.', 'data' => null], 403);
- }
-
- global $wpdb;
-
- $user_id = intval($request->get_param('user_id'));
- $event_id = intval($request->get_param('event_id'));
- $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
- $start_time = sanitize_text_field($request->get_param('meeting_start_time'));
- $end_time = sanitize_text_field($request->get_param('meeting_end_time'));
- $participants = $request->get_param('meeting_participants');
- $message = sanitize_textarea_field($request->get_param('write_a_message'));
-
- if (!$user_id || !get_userdata($user_id) || empty($meeting_date) || empty($start_time) || empty($end_time) || empty($participants) || !is_array($participants)) {
- return new WP_REST_Response(['code' => 400, 'status' => 'Bad Request', 'message' => 'Missing or invalid parameters.', 'data' => []], 400);
- }
-
- // Filter out the user themselves from participant list
- $participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
- $participants = array_fill_keys($participants, -1);
-
- $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $inserted = $wpdb->insert($table, [
- 'user_id' => $user_id,
- 'event_id' => $event_id,
- 'participant_ids' => serialize($participants),
- 'meeting_date' => $meeting_date,
- 'meeting_start_time' => $start_time,
- 'meeting_end_time' => $end_time,
- 'message' => $message,
- 'meeting_status' => 0
- ], ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']);
-
- if (!$inserted) {
- return new WP_REST_Response(['code' => 500, 'status' => 'Internal Server Error', 'message' => 'Could not create meeting.', 'data' => []], 500);
- }
-
- $meeting_id = $wpdb->insert_id;
- $formatted_date = date("l, d F Y", strtotime($meeting_date));
- $formatted_start_time = date("h:i A", strtotime($start_time));
- $formatted_end_time = date("h:i A", strtotime($end_time));
- $sender_user = get_userdata($user_id);
-
- $participant_details = [];
-
- if (!empty($participants)) {
- $profile_table = $wpdb->prefix . 'wpem_matchmaking_users';
- $placeholders = implode(',', array_fill(0, count($participants), '%d'));
- $query = $wpdb->prepare("SELECT * FROM $profile_table WHERE user_id IN ($placeholders)", ...$participants);
- $results = $wpdb->get_results($query, ARRAY_A);
-
- foreach ($results as $participant) {
- $participant_user = get_userdata($participant['user_id']);
- $participant_name = $participant_user->display_name ?? 'User';
- $participant_email = $participant_user->user_email ?? '';
- $profile_picture = $participant['profile_photo'] ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
-
- $participant_details[] = [
- 'name' => $participant_name,
- 'profession' => $participant['profession'] ?? '',
- 'profile_picture' => esc_url($profile_picture)
- ];
-
- // Email to participant
- $host_profile = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d", $user_id), ARRAY_A);
- $host_company = $host_profile['company_name'] ?? '';
- $host_city = $host_profile['city'] ?? '';
- $all_countries = wpem_registration_get_all_countries();
- $host_country = $all_countries[$host_profile['country']] ?? '';
- $event_name = get_the_title($event_id) ?: '';
- $timezone_abbr = wp_timezone_string();
-
- $subject = "{$sender_user->display_name} requested a meeting with you";
- $body = "
- Hello {$participant_name},
- {$sender_user->display_name} has requested a meeting with you.
- Event: {$event_name}
- Date: {$formatted_date}
- Time: {$formatted_start_time} – {$formatted_end_time} {$timezone_abbr}
- Company: {$host_company}
- City: {$host_city}
- Country: {$host_country}
- Message: {$message}
- ";
-
- wp_mail($participant_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
- }
- }
-
- // Email to sender
- $participant_names = implode(', ', array_column($participant_details, 'name'));
- wp_mail(
- $sender_user->user_email,
- 'Your Meeting Request Has Been Sent',
- "
- Hello {$sender_user->display_name},
- Your meeting request has been sent to: {$participant_names} .
- Date: {$formatted_date}
- Time: {$formatted_start_time} - {$formatted_end_time}
- Message: {$message}
- ",
- ['Content-Type: text/html; charset=UTF-8']
- );
// Update booked slot (2) for all participants and host
$availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
$all_user_ids = array_merge([ $user_id ], array_keys($participants)); // host + participant IDs
@@ -232,7 +248,6 @@ public function create_meeting(WP_REST_Request $request) {
$slot_data = [];
}
- // Ensure keys exist
if (!isset($slot_data[$event_id])) {
$slot_data[$event_id] = [];
}
@@ -240,10 +255,8 @@ public function create_meeting(WP_REST_Request $request) {
$slot_data[$event_id][$meeting_date] = [];
}
- // Mark the start_time slot as booked (2)
- $slot_data[$event_id][$meeting_date][$start_time] = 2;
+ $slot_data[$event_id][$meeting_date][$slot] = 2;
- // Update in DB
$wpdb->update(
$availability_table,
['meeting_availability_slot' => maybe_serialize($slot_data)],
@@ -252,20 +265,19 @@ public function create_meeting(WP_REST_Request $request) {
['%d']
);
}
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Meeting created and emails sent!',
- 'data' => [
- 'meeting_date' => $formatted_date,
- 'start_time' => $formatted_start_time,
- 'end_time' => $formatted_end_time,
- 'participants' => $participant_details,
- 'message' => $message
- ]
- ], 200);
- }
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meeting created and emails sent!',
+ 'data' => [
+ 'meeting_date' => $formatted_date,
+ 'time' => $formatted_time,
+ 'participants' => $participant_details,
+ 'message' => $message
+ ]
+ ], 200);
+ }
public function get_user_meetings(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
From fb91a43356d26eb7c42d09d5aa59ca61e6e5800f Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 8 Jul 2025 16:51:03 +0530
Subject: [PATCH 080/171] #176
---
.../wpem-rest-matchmaking-create-meetings.php | 94 ++++++++++---------
1 file changed, 52 insertions(+), 42 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index b1353c4..e9e4cfa 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -233,39 +233,6 @@ public function create_meeting(WP_REST_Request $request) {
['Content-Type: text/html; charset=UTF-8']
);
- // Update booked slot (2) for all participants and host
- $availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
- $all_user_ids = array_merge([ $user_id ], array_keys($participants)); // host + participant IDs
-
- foreach ($all_user_ids as $uid) {
- $serialized = $wpdb->get_var($wpdb->prepare(
- "SELECT meeting_availability_slot FROM $availability_table WHERE user_id = %d",
- $uid
- ));
-
- $slot_data = maybe_unserialize($serialized);
- if (!is_array($slot_data)) {
- $slot_data = [];
- }
-
- if (!isset($slot_data[$event_id])) {
- $slot_data[$event_id] = [];
- }
- if (!isset($slot_data[$event_id][$meeting_date])) {
- $slot_data[$event_id][$meeting_date] = [];
- }
-
- $slot_data[$event_id][$meeting_date][$slot] = 2;
-
- $wpdb->update(
- $availability_table,
- ['meeting_availability_slot' => maybe_serialize($slot_data)],
- ['user_id' => $uid],
- ['%s'],
- ['%d']
- );
- }
-
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
@@ -511,6 +478,7 @@ public function update_meeting_status(WP_REST_Request $request) {
'data' => null
], 403);
}
+
global $wpdb;
$meeting_id = intval($request->get_param('meeting_id'));
@@ -522,7 +490,11 @@ public function update_meeting_status(WP_REST_Request $request) {
}
$table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $meeting = $wpdb->get_row($wpdb->prepare("SELECT participant_ids FROM $table WHERE id = %d", $meeting_id));
+ $meeting = $wpdb->get_row($wpdb->prepare("
+ SELECT participant_ids, event_id, meeting_date, meeting_start_time
+ FROM $table
+ WHERE id = %d", $meeting_id
+ ));
if (!$meeting) {
return new WP_REST_Response(['code' => 404, 'message' => 'Meeting not found.'], 404);
@@ -537,13 +509,13 @@ public function update_meeting_status(WP_REST_Request $request) {
return new WP_REST_Response(['code' => 403, 'message' => 'You are not a participant of this meeting.'], 403);
}
- // Update current user's status
+ // Update participant's status
$participant_data[$user_id] = $new_status;
- // If at least one participant has accepted (status = 1), mark meeting as accepted
+ // Determine meeting status
$meeting_status = (in_array(1, $participant_data, true)) ? 1 : 0;
- // Update in DB
+ // Update participant_ids and meeting_status in meeting table
$updated = $wpdb->update(
$table,
[
@@ -559,19 +531,57 @@ public function update_meeting_status(WP_REST_Request $request) {
return new WP_REST_Response(['code' => 500, 'message' => 'Failed to update status.'], 500);
}
+ // Update user's meeting_availability_slot based on acceptance
+ $event_id = $meeting->event_id;
+ $meeting_date = $meeting->meeting_date;
+ $slot = date('H:i', strtotime($meeting->meeting_start_time));
+
+ $availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ $serialized = $wpdb->get_var($wpdb->prepare(
+ "SELECT meeting_availability_slot FROM $availability_table WHERE user_id = %d",
+ $user_id
+ ));
+
+ $slot_data = maybe_unserialize($serialized);
+ if (!is_array($slot_data)) {
+ $slot_data = [];
+ }
+
+ if (!isset($slot_data[$event_id])) {
+ $slot_data[$event_id] = [];
+ }
+ if (!isset($slot_data[$event_id][$meeting_date])) {
+ $slot_data[$event_id][$meeting_date] = [];
+ }
+
+ // Set slot status based on new_status
+ if ($new_status === 1) {
+ $slot_data[$event_id][$meeting_date][$slot] = 2; // Booked
+ } elseif ($new_status === 0) {
+ $slot_data[$event_id][$meeting_date][$slot] = 1; // Available
+ }
+
+ $wpdb->update(
+ $availability_table,
+ ['meeting_availability_slot' => maybe_serialize($slot_data)],
+ ['user_id' => $user_id],
+ ['%s'],
+ ['%d']
+ );
+
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
'message' => $new_status ? 'Meeting accepted.' : 'Meeting declined.',
'data' => [
- 'meeting_id' => $meeting_id,
- 'participant_id' => $user_id,
+ 'meeting_id' => $meeting_id,
+ 'participant_id' => $user_id,
'participant_status' => $new_status,
- 'meeting_status' => $meeting_status,
+ 'meeting_status' => $meeting_status,
]
], 200);
- }
- public function get_booked_meeting_slots(WP_REST_Request $request) {
+ } public function get_booked_meeting_slots(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
'code' => 403,
From 8fc05c1eaa0a7faaf846a2c2c3953cf12a16e9c4 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 8 Jul 2025 17:45:51 +0530
Subject: [PATCH 081/171] #176
---
.../wpem-rest-matchmaking-create-meetings.php | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index e9e4cfa..de20864 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -232,6 +232,37 @@ public function create_meeting(WP_REST_Request $request) {
",
['Content-Type: text/html; charset=UTF-8']
);
+ // Update booked slot (2) for the host only
+ $availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
+
+ $serialized = $wpdb->get_var($wpdb->prepare(
+ "SELECT meeting_availability_slot FROM $availability_table WHERE user_id = %d",
+ $user_id
+ ));
+
+ $slot_data = maybe_unserialize($serialized);
+ if (!is_array($slot_data)) {
+ $slot_data = [];
+ }
+
+ if (!isset($slot_data[$event_id])) {
+ $slot_data[$event_id] = [];
+ }
+ if (!isset($slot_data[$event_id][$meeting_date])) {
+ $slot_data[$event_id][$meeting_date] = [];
+ }
+
+ // Set slot as 2 (booked)
+ $slot_data[$event_id][$meeting_date][$slot] = 2;
+
+ // Update DB for host only
+ $wpdb->update(
+ $availability_table,
+ ['meeting_availability_slot' => maybe_serialize($slot_data)],
+ ['user_id' => $user_id],
+ ['%s'],
+ ['%d']
+ );
return new WP_REST_Response([
'code' => 200,
From f9d27c6c681afb557230f5e92e8b78eb6e3ea48d Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 10 Jul 2025 10:45:10 +0530
Subject: [PATCH 082/171] #176 APIs For availability of meeting slots
---
.../wpem-rest-matchmaking-create-meetings.php | 57 +++++++++++++------
1 file changed, 40 insertions(+), 17 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index de20864..6f9f077 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -500,7 +500,7 @@ public function cancel_meeting(WP_REST_Request $request) {
'data' => ['meeting_id' => $meeting_id],
], 200);
}
- public function update_meeting_status(WP_REST_Request $request) {
+ public function update_meeting_status(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
'code' => 403,
@@ -521,6 +521,7 @@ public function update_meeting_status(WP_REST_Request $request) {
}
$table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+
$meeting = $wpdb->get_row($wpdb->prepare("
SELECT participant_ids, event_id, meeting_date, meeting_start_time
FROM $table
@@ -540,13 +541,43 @@ public function update_meeting_status(WP_REST_Request $request) {
return new WP_REST_Response(['code' => 403, 'message' => 'You are not a participant of this meeting.'], 403);
}
- // Update participant's status
+ // If user is accepting, check for conflict in same slot
+ if ($new_status === 1) {
+ $event_id = $meeting->event_id;
+ $meeting_date = $meeting->meeting_date;
+ $slot = date('H:i', strtotime($meeting->meeting_start_time));
+
+ $conflicting_meeting = $wpdb->get_row($wpdb->prepare("
+ SELECT id FROM $table
+ WHERE id != %d
+ AND event_id = %d
+ AND meeting_date = %s
+ AND meeting_start_time = %s
+ AND meeting_status != -1
+ ", $meeting_id, $event_id, $meeting_date, $meeting->meeting_start_time));
+
+ if ($conflicting_meeting) {
+ $existing_participants = $wpdb->get_var($wpdb->prepare("
+ SELECT participant_ids FROM $table WHERE id = %d
+ ", $conflicting_meeting->id));
+
+ $existing_participant_data = maybe_unserialize($existing_participants);
+ if (is_array($existing_participant_data) && isset($existing_participant_data[$user_id]) && $existing_participant_data[$user_id] == 1) {
+ return new WP_REST_Response([
+ 'code' => 409,
+ 'message' => 'You already have a confirmed meeting scheduled at this time slot.',
+ ], 409);
+ }
+ }
+ }
+
+ // Update this user's status
$participant_data[$user_id] = $new_status;
- // Determine meeting status
+ // Determine overall meeting status
$meeting_status = (in_array(1, $participant_data, true)) ? 1 : 0;
- // Update participant_ids and meeting_status in meeting table
+ // Update meeting record
$updated = $wpdb->update(
$table,
[
@@ -559,14 +590,10 @@ public function update_meeting_status(WP_REST_Request $request) {
);
if ($updated === false) {
- return new WP_REST_Response(['code' => 500, 'message' => 'Failed to update status.'], 500);
+ return new WP_REST_Response(['code' => 500, 'message' => 'Failed to update meeting status.'], 500);
}
- // Update user's meeting_availability_slot based on acceptance
- $event_id = $meeting->event_id;
- $meeting_date = $meeting->meeting_date;
- $slot = date('H:i', strtotime($meeting->meeting_start_time));
-
+ // Update availability slot for this user
$availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
$serialized = $wpdb->get_var($wpdb->prepare(
@@ -586,12 +613,7 @@ public function update_meeting_status(WP_REST_Request $request) {
$slot_data[$event_id][$meeting_date] = [];
}
- // Set slot status based on new_status
- if ($new_status === 1) {
- $slot_data[$event_id][$meeting_date][$slot] = 2; // Booked
- } elseif ($new_status === 0) {
- $slot_data[$event_id][$meeting_date][$slot] = 1; // Available
- }
+ $slot_data[$event_id][$meeting_date][date('H:i', strtotime($meeting->meeting_start_time))] = ($new_status === 1) ? 2 : 1;
$wpdb->update(
$availability_table,
@@ -612,7 +634,8 @@ public function update_meeting_status(WP_REST_Request $request) {
'meeting_status' => $meeting_status,
]
], 200);
- } public function get_booked_meeting_slots(WP_REST_Request $request) {
+ }
+ public function get_booked_meeting_slots(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
'code' => 403,
From bcab5b3b38d0e4bc3dfacc73df2cde6d26cdafa5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 15 Jul 2025 11:36:48 +0530
Subject: [PATCH 083/171] #181 Settings API for meetings settings
---
.../wpem-rest-matchmaking-create-meetings.php | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 6f9f077..8081578 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -109,6 +109,11 @@ public function register_routes() {
],
]
]);
+ register_rest_route($this->namespace, '/matchmaking-settings', [
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => [$this, 'get_matchmaking_settings'],
+ 'permission_callback' => '__return_true', // if no auth needed
+ ]);
}
public function create_meeting(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
@@ -864,6 +869,32 @@ public function get_common_availability_slots($request) {
],
]);
}
+ public function get_matchmaking_settings(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking is disabled.',
+ 'data' => null
+ ], 403);
+ }
+
+ $settings = [
+ 'request_mode' => get_option('wpem_meeting_request_mode'),
+ 'scheduling_mode' => get_option('wpem_meeting_scheduling_mode'),
+ 'attendee_limit' => get_option('wpem_meeting_attendee_limit'),
+ 'meeting_expiration' => get_option('wpem_meeting_expiration'),
+ 'enable_matchmaking' => get_option('enable_matchmaking'),
+ 'participant_activation' => get_option('participant_activation'),
+ ];
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Matchmaking settings retrieved.',
+ 'data' => $settings
+ ], 200);
+ }
}
new WPEM_REST_Create_Meeting_Controller();
From b5ebb1d95cfc73567e702e614ffc2e8c2d1c9adf Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 15 Jul 2025 12:16:53 +0530
Subject: [PATCH 084/171] #180 Send Message Image field added
---
.../wpem-rest-matchmaking-user-messages.php | 194 +++++++++---------
1 file changed, 101 insertions(+), 93 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 9eb8076..ec439ed 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -12,16 +12,17 @@ public function __construct() {
public function register_routes() {
$auth_controller = new WPEM_REST_Authentication();
- register_rest_route($this->namespace, '/' . $this->rest_base, array(
- 'methods' => WP_REST_Server::CREATABLE,
- 'callback' => array($this, 'handle_send_message'),
- 'permission_callback' => array($auth_controller, 'check_authentication'),
- 'args' => array(
- 'senderId' => array('required' => true, 'type' => 'integer'),
- 'receiverId' => array('required' => true, 'type' => 'integer'),
- 'message' => array('required' => true, 'type' => 'string'),
- ),
- ));
+ register_rest_route($this->namespace, '/' . $this->rest_base, array(
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array($this, 'handle_send_message'),
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
+ 'args' => array(
+ 'senderId' => array('required' => true),
+ 'receiverId' => array('required' => true),
+ 'message' => array('required' => false),
+ 'image' => array('required' => false),
+ ),
+ ));
register_rest_route($this->namespace, '/get-messages', array(
'methods' => WP_REST_Server::READABLE,
@@ -47,60 +48,76 @@ public function register_routes() {
),
));
}
+ public function handle_send_message($request) {
+ global $wpdb;
- public function handle_send_message($request) {
- global $wpdb;
-
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response(array(
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ), 403);
- }
-
- $sender_id = intval($request->get_param('senderId'));
- $receiver_id = intval($request->get_param('receiverId'));
- $message = sanitize_textarea_field($request->get_param('message'));
-
- $sender_user = get_user_by('id', $sender_id);
- $receiver_user = get_user_by('id', $receiver_id);
- if (!$sender_user || !$receiver_user) {
- return new WP_REST_Response([
- 'code' => 404,
- 'status' => 'Not Found',
- 'message' => 'Sender or Receiver not found.',
- 'data' => null
- ], 404);
- }
- // Check message_notification in wp_wpem_matchmaking_users table
- $table_users = $wpdb->prefix . 'wpem_matchmaking_users';
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ ], 403);
+ }
- $sender_notify = $wpdb->get_var(
- $wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $sender_id)
- );
+ $sender_id = intval($request->get_param('senderId'));
+ $receiver_id = intval($request->get_param('receiverId'));
+ $text_message = sanitize_textarea_field($request->get_param('message'));
- $receiver_notify = $wpdb->get_var(
- $wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $receiver_id)
- );
+ $sender_user = get_user_by('id', $sender_id);
+ $receiver_user = get_user_by('id', $receiver_id);
+
+ if (!$sender_user || !$receiver_user) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'Sender or Receiver not found.',
+ ], 404);
+ }
+
+ // Check message notifications
+ $table_users = $wpdb->prefix . 'wpem_matchmaking_users';
+ $sender_notify = $wpdb->get_var($wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $sender_id));
+ $receiver_notify = $wpdb->get_var($wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $receiver_id));
if ($sender_notify != 1 || $receiver_notify != 1) {
return new WP_REST_Response([
'code' => 403,
'status' => 'Forbidden',
- 'message' => 'Both sender and receiver must have message notifications enabled to send messages.',
+ 'message' => 'Both sender and receiver must have message notifications enabled.',
], 403);
}
- $first_name = get_user_meta($sender_id, 'first_name', true);
- $last_name = get_user_meta($sender_id, 'last_name', true);
+ // Handle file upload if present
+ $uploaded_file_url = '';
+ if (!empty($_FILES['image']) && !empty($_FILES['image']['tmp_name'])) {
+ require_once ABSPATH . 'wp-admin/includes/file.php';
+ $uploaded = wp_handle_upload($_FILES['image'], ['test_form' => false]);
- // Determine parent_id (new conversation for the day = parent_id 1)
- $table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
- $today = date('Y-m-d');
+ if (!isset($uploaded['error'])) {
+ $uploaded_file_url = esc_url_raw($uploaded['url']);
+ }
+ }
- $first_message_id = $wpdb->get_var($wpdb->prepare(
+ // Final message logic
+ $final_message = '';
+ if ($text_message && $uploaded_file_url) {
+ $final_message = $text_message . "\n\n" . $uploaded_file_url;
+ } elseif ($text_message) {
+ $final_message = $text_message;
+ } elseif ($uploaded_file_url) {
+ $final_message = $uploaded_file_url;
+ } else {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'Message or image is required.',
+ ], 400);
+ }
+
+ // Save message
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
+
+ $first_message_id = $wpdb->get_var($wpdb->prepare(
"SELECT id FROM $table
WHERE (sender_id = %d AND receiver_id = %d)
OR (sender_id = %d AND receiver_id = %d)
@@ -108,49 +125,40 @@ public function handle_send_message($request) {
$sender_id, $receiver_id,
$receiver_id, $sender_id
));
+ $parent_id = $first_message_id ?: 0;
+
+ $wpdb->insert($table, [
+ 'parent_id' => $parent_id,
+ 'sender_id' => $sender_id,
+ 'receiver_id' => $receiver_id,
+ 'message' => $final_message,
+ 'created_at' => current_time('mysql')
+ ], ['%d', '%d', '%d', '%s', '%s']);
+
+ $insert_id = $wpdb->insert_id;
+
+ // Send email
+ wp_mail(
+ $receiver_user->user_email,
+ 'New Message from ' . $sender_user->display_name,
+ $final_message,
+ ['Content-Type: text/plain; charset=UTF-8']
+ );
- $parent_id = $first_message_id ? $first_message_id : 0;
-
- $inserted = $wpdb->insert($table, array(
- 'parent_id' => $parent_id,
- 'sender_id' => $sender_id,
- 'receiver_id' => $receiver_id,
- 'message' => $message,
- 'created_at' => current_time('mysql')
- ), array('%d', '%d', '%d', '%s', '%s'));
-
- if (!$inserted) {
- return new WP_REST_Response([
- 'code' => 500,
- 'status' => 'Error',
- 'message' => 'Failed to save message.',
- 'data' => $wpdb->last_error
- ], 500);
- }
-
- wp_mail(
- $receiver_user->user_email,
- 'New Message from ' . $sender_user->display_name,
- "You have received a new message:\n\n" . $message . "\n\nFrom: " . $sender_user->display_name,
- array('Content-Type: text/plain; charset=UTF-8')
- );
-
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Message sent and saved successfully.',
- 'data' => array(
- 'id' => $wpdb->insert_id,
- 'parent_id' => $parent_id,
- 'sender_id' => $sender_id,
- 'receiver_id'=> $receiver_id,
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'message' => $message,
- 'created_at' => current_time('mysql'),
- )
- ], 200);
- }
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Message sent successfully.',
+ 'data' => [
+ 'id' => $insert_id,
+ 'parent_id' => $parent_id,
+ 'sender_id' => $sender_id,
+ 'receiver_id'=> $receiver_id,
+ 'message' => $final_message,
+ 'created_at' => current_time('mysql'),
+ ]
+ ], 200);
+ }
public function handle_get_messages($request) {
global $wpdb;
From 923b5891bce941ab9a4c0aadbb265879c2c9e552 Mon Sep 17 00:00:00 2001
From: Rita
Date: Tue, 15 Jul 2025 12:17:57 +0530
Subject: [PATCH 085/171] Password change then user should auto logout from
mobile app #172
---
includes/wpem-rest-authentication.php | 26 ++++++++++++++------
includes/wpem-rest-crud-controller.php | 33 ++++++++++++++------------
2 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index 0669f4d..148c052 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -685,7 +685,7 @@ public function perform_user_authentication($request){
$user_id = $user->ID;
- $token = $this->wpem_generate_jwt_token($user->ID);
+ $token = $this->wpem_generate_jwt_token($user->ID, $password);
$is_matchmaking = get_user_meta($user_id, '_matchmaking_profile', true);
$enable_matchmaking = get_option('enable_matchmaking', false) ? 1 : 0;
@@ -776,17 +776,19 @@ public function perform_user_authentication($request){
* This function will used to generate jwt token for individual user
* @since 1.0.9
*/
- public function wpem_generate_jwt_token($user_id) {
+ public function wpem_generate_jwt_token($user_id, $password) {
$user = get_userdata($user_id);
if (!$user) return false;
// Header and payload
$header = wpem_base64url_encode(json_encode(['alg' => 'HS256', 'typ' => 'JWT']));
+
$payload = wpem_base64url_encode(json_encode([
'iss' => get_bloginfo('url'),
'user' => [
'id' => $user->ID,
- 'username' => $user->user_login
+ 'username' => $user->user_login,
+ 'password' => $password
]
]));
@@ -824,19 +826,29 @@ private function validate_jwt_token($token) {
list($header_b64, $payload_b64, $signature_b64) = $parts;
+ // Recalculate the signature
$expected_signature = wpem_base64url_encode(
hash_hmac('sha256', "$header_b64.$payload_b64", JWT_SECRET_KEY, true)
);
+ // Timing-attack-safe comparison
if (!hash_equals($expected_signature, $signature_b64)) {
- return new WP_Error( 'rest_forbidden', __( 'Invalid token signature.', 'textdomain' ), array( 'status' => 401 ) );
+ return new WP_Error( 'rest_forbidden', __( 'Invalid token signature.', 'textdomain' ), [ 'status' => 401 ] );
}
- $payload = json_decode(base64_decode(strtr($payload_b64, '-_', '+/')), true);
- if (!isset($payload['user']['id'])) {
- return new WP_Error( 'rest_forbidden', __( 'Invalid token payload.', 'textdomain' ), array( 'status' => 401 ) );
+ // Decode payload
+ $payload_json = base64_decode(strtr($payload_b64, '-_', '+/'));
+ $payload = json_decode($payload_json, true);
+
+ if (json_last_error() !== JSON_ERROR_NONE || !isset($payload['user']['id'])) {
+ return new WP_Error( 'rest_forbidden', __( 'Invalid token payload.', 'textdomain' ), [ 'status' => 401 ] );
}
+ // Optionally: check expiration
+ if (isset($payload['exp']) && time() > $payload['exp']) {
+ return new WP_Error( 'rest_forbidden', __( 'Token has expired.', 'textdomain' ), [ 'status' => 401 ] );
+ }
+ // Return decoded payload if needed
return true;
}
diff --git a/includes/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
index ebcea31..fd3ca82 100644
--- a/includes/wpem-rest-crud-controller.php
+++ b/includes/wpem-rest-crud-controller.php
@@ -750,26 +750,29 @@ public function wpem_check_authorized_user() {
* @since 1.0.9
*/
public static function wpem_validate_jwt_token($token) {
- // Extract the JWT parts
$parts = explode('.', $token);
- if (count($parts) !== 3) {
+ if (count($parts) !== 3) return false;
+
+ list($header, $payload, $signature) = $parts;
+
+ $expected_signature = wpem_base64url_encode(
+ hash_hmac('sha256', "$header.$payload", JWT_SECRET_KEY, true)
+ );
+
+ if (!hash_equals($expected_signature, $signature)) {
return false;
}
- list($encodedHeader, $encodedPayload, $encodedSignature) = $parts;
-
- $payload_json = wpem_base64url_decode($encodedPayload);
- $payload = json_decode($payload_json, true);
-
- // Re-generate signature
- $signature = hash_hmac('sha256', "$encodedHeader.$encodedPayload", JWT_SECRET_KEY, true);
- $expected_signature = wpem_base64url_encode(hash_hmac('sha256', "$encodedHeader.$encodedPayload", JWT_SECRET_KEY, true));
-
- if ($expected_signature === $encodedSignature) {
- $payload = json_decode(wpem_base64url_decode($encodedPayload), true);
- return $payload['user'];
+ $payload_json = wpem_base64url_decode($payload);
+ $payload_data = json_decode($payload_json, true);
+ if (json_last_error() !== JSON_ERROR_NONE || !isset($payload_data['user'])) {
+ return false;
}
- return false;
+
+ // Clean up keys (defensive)
+ $user = array_change_key_case(array_map('trim', $payload_data['user']));
+
+ return $user;
}
/**
From b43498f2bd0cbaa7d4842dd78a96ab81026a4666 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 15 Jul 2025 12:37:11 +0530
Subject: [PATCH 086/171] #180 Image attach feature in chat
---
.../wpem-rest-matchmaking-user-messages.php | 46 ++++++++-----------
1 file changed, 19 insertions(+), 27 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index ec439ed..d7e8e47 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -59,11 +59,10 @@ public function handle_send_message($request) {
], 403);
}
- $sender_id = intval($request->get_param('senderId'));
- $receiver_id = intval($request->get_param('receiverId'));
- $text_message = sanitize_textarea_field($request->get_param('message'));
-
- $sender_user = get_user_by('id', $sender_id);
+ $sender_id = intval($request->get_param('senderId'));
+ $receiver_id = intval($request->get_param('receiverId'));
+ $text_message = sanitize_textarea_field($request->get_param('message'));
+ $sender_user = get_user_by('id', $sender_id);
$receiver_user = get_user_by('id', $receiver_id);
if (!$sender_user || !$receiver_user) {
@@ -74,7 +73,6 @@ public function handle_send_message($request) {
], 404);
}
- // Check message notifications
$table_users = $wpdb->prefix . 'wpem_matchmaking_users';
$sender_notify = $wpdb->get_var($wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $sender_id));
$receiver_notify = $wpdb->get_var($wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $receiver_id));
@@ -87,36 +85,31 @@ public function handle_send_message($request) {
], 403);
}
- // Handle file upload if present
- $uploaded_file_url = '';
- if (!empty($_FILES['image']) && !empty($_FILES['image']['tmp_name'])) {
+ $image_url = '';
+ if (!empty($_FILES['image']['tmp_name'])) {
require_once ABSPATH . 'wp-admin/includes/file.php';
$uploaded = wp_handle_upload($_FILES['image'], ['test_form' => false]);
-
if (!isset($uploaded['error'])) {
- $uploaded_file_url = esc_url_raw($uploaded['url']);
+ $image_url = esc_url_raw($uploaded['url']);
}
}
-
- // Final message logic
+
$final_message = '';
- if ($text_message && $uploaded_file_url) {
- $final_message = $text_message . "\n\n" . $uploaded_file_url;
+ if ($text_message && $image_url) {
+ $final_message = $text_message . "\n\n" . $image_url;
} elseif ($text_message) {
$final_message = $text_message;
- } elseif ($uploaded_file_url) {
- $final_message = $uploaded_file_url;
+ } elseif ($image_url) {
+ $final_message = $image_url;
} else {
return new WP_REST_Response([
'code' => 400,
'status' => 'Bad Request',
- 'message' => 'Message or image is required.',
+ 'message' => 'Either message or image is required.',
], 400);
}
- // Save message
$table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
-
$first_message_id = $wpdb->get_var($wpdb->prepare(
"SELECT id FROM $table
WHERE (sender_id = %d AND receiver_id = %d)
@@ -137,7 +130,6 @@ public function handle_send_message($request) {
$insert_id = $wpdb->insert_id;
- // Send email
wp_mail(
$receiver_user->user_email,
'New Message from ' . $sender_user->display_name,
@@ -146,20 +138,20 @@ public function handle_send_message($request) {
);
return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Message sent successfully.',
- 'data' => [
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Message sent successfully.',
+ 'data' => [
'id' => $insert_id,
'parent_id' => $parent_id,
'sender_id' => $sender_id,
'receiver_id'=> $receiver_id,
- 'message' => $final_message,
+ 'message' => $text_message ?: null,
+ 'image' => $image_url ?: null,
'created_at' => current_time('mysql'),
]
], 200);
}
-
public function handle_get_messages($request) {
global $wpdb;
From ffc7b04c8436c2db4c46d472b6d43c83a49dadab Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 28 Jul 2025 21:31:58 +0530
Subject: [PATCH 087/171] #182 Changes in Match making APIs due to changes in
database table changes
---
.../wpem-rest-matchmaking-filter-users.php | 403 ++++++++-------
includes/wpem-rest-matchmaking-profile.php | 478 ++++++++++--------
2 files changed, 487 insertions(+), 394 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 142aca8..41da1f6 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -156,208 +156,251 @@ public function handle_your_matches($request) {
return $response;
}
- public function handle_filter_users($request) {
- global $wpdb;
-
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
+public function handle_filter_users($request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $where_clauses = [];
- $query_params = [];
- $user_ids = [];
-
- $event_id = $request->get_param('event_id');
- $current_user_id = $request->get_param('user_id');
-
- if (!empty($event_id)) {
- if (!$current_user_id) {
- return new WP_REST_Response([
- 'code' => 401,
- 'status' => 'Unauthorized',
- 'message' => 'User not logged in.',
- 'data' => []
- ], 401);
- }
-
- $registration_query = new WP_Query([
- 'post_type' => 'event_registration',
- 'posts_per_page' => -1,
- 'fields' => 'ids',
- 'meta_query' => [
- ['key' => '_attendee_user_id', 'value' => $current_user_id],
- ['key' => '_event_id', 'value' => $event_id],
- ],
- ]);
-
- if (!$registration_query->have_posts()) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Forbidden',
- 'message' => 'You are not registered for this event.',
- 'data' => []
- ], 403);
- }
-
- $attendee_query = new WP_Query([
- 'post_type' => 'event_registration',
- 'posts_per_page' => -1,
- 'fields' => 'ids',
- 'meta_query' => [['key' => '_event_id', 'value' => $event_id]],
- ]);
-
- foreach ($attendee_query->posts as $post_id) {
- $uid = get_post_meta($post_id, '_attendee_user_id', true);
- if ($uid && $uid != $current_user_id && !in_array($uid, $user_ids)) {
- $user_ids[] = (int)$uid;
- }
- }
-
- if (empty($user_ids)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No attendees found for this event.',
- 'data' => []
- ], 200);
- }
-
- $placeholders = implode(',', array_fill(0, count($user_ids), '%d'));
- $where_clauses[] = "user_id IN ($placeholders)";
- $query_params = array_merge($query_params, $user_ids);
- }
+ $event_id = $request->get_param('event_id');
+ $current_user_id = $request->get_param('user_id');
+ $user_ids = [];
+
+ // Handle event-specific filtering
+ if (!empty($event_id)) {
+ if (!$current_user_id) {
+ return new WP_REST_Response([
+ 'code' => 401,
+ 'status' => 'Unauthorized',
+ 'message' => 'User not logged in.',
+ 'data' => []
+ ], 401);
+ }
- if ($profession = sanitize_text_field($request->get_param('profession'))) {
- $where_clauses[] = "profession = %s";
- $query_params[] = $profession;
- }
+ // Check if current user is registered for the event
+ $registration_query = new WP_Query([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => [
+ ['key' => '_attendee_user_id', 'value' => $current_user_id],
+ ['key' => '_event_id', 'value' => $event_id],
+ ],
+ ]);
+
+ if (!$registration_query->have_posts()) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Forbidden',
+ 'message' => 'You are not registered for this event.',
+ 'data' => []
+ ], 403);
+ }
- $experience = $request->get_param('experience');
- if (is_array($experience) && isset($experience['min'], $experience['max'])) {
- $where_clauses[] = "experience BETWEEN %d AND %d";
- $query_params[] = (int)$experience['min'];
- $query_params[] = (int)$experience['max'];
- } elseif (is_numeric($experience)) {
- $where_clauses[] = "experience = %d";
- $query_params[] = (int)$experience;
- }
+ // Get all attendees for this event
+ $attendee_query = new WP_Query([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => [['key' => '_event_id', 'value' => $event_id]],
+ ]);
+
+ foreach ($attendee_query->posts as $post_id) {
+ $uid = get_post_meta($post_id, '_attendee_user_id', true);
+ if ($uid && $uid != $current_user_id && !in_array($uid, $user_ids)) {
+ $user_ids[] = (int)$uid;
+ }
+ }
- if ($company = sanitize_text_field($request->get_param('company_name'))) {
- $where_clauses[] = "company_name = %s";
- $query_params[] = $company;
- }
+ if (empty($user_ids)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No attendees found for this event.',
+ 'data' => []
+ ], 200);
+ }
+ }
- $countries = $request->get_param('country');
- if (is_array($countries)) {
- $placeholders = implode(',', array_fill(0, count($countries), '%s'));
- $where_clauses[] = "country IN ($placeholders)";
- $query_params = array_merge($query_params, array_map('sanitize_text_field', $countries));
- } elseif (!empty($countries)) {
- $country = sanitize_text_field($countries);
- $where_clauses[] = "country = %s";
- $query_params[] = $country;
- }
+ // Get all users with matchmaking profile first
+ $all_users = get_users([
+ 'meta_key' => '_matchmaking_profile',
+ 'meta_value' => '1',
+ 'meta_compare' => '=',
+ ]);
- if ($city = sanitize_text_field($request->get_param('city'))) {
- $where_clauses[] = "city = %s";
- $query_params[] = $city;
- }
+ // Filter users based on criteria
+ $filtered_users = array_filter($all_users, function($user) use ($request, $user_ids) {
+ $user_meta = get_user_meta($user->ID);
+
+ // If event_id provided, only include users in the attendee list
+ if (!empty($user_ids) && !in_array($user->ID, $user_ids)) {
+ return false;
+ }
- $skills = $request->get_param('skills');
- if (is_array($skills) && !empty($skills)) {
- foreach ($skills as $skill) {
- $like = '%' . $wpdb->esc_like(serialize($skill)) . '%';
- $where_clauses[] = "skills LIKE %s";
- $query_params[] = $like;
- }
- }
+ // Profession filter
+ if ($profession = sanitize_text_field($request->get_param('profession'))) {
+ if (empty($user_meta['_profession'][0])) return false;
+ if (strcasecmp($user_meta['_profession'][0], $profession) !== 0)
+ return false;
+ }
- $interests = $request->get_param('interests');
- if (is_array($interests) && !empty($interests)) {
- foreach ($interests as $interest) {
- $like = '%' . $wpdb->esc_like(serialize($interest)) . '%';
- $where_clauses[] = "interests LIKE %s";
- $query_params[] = $like;
- }
- }
+ // Experience filter
+ $experience = $request->get_param('experience');
+ if (is_array($experience)) {
+ $user_exp = isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0;
+ if (isset($experience['min']) && is_numeric($experience['min']) && $user_exp < (float)$experience['min']) {
+ return false;
+ }
+ if (isset($experience['max']) && is_numeric($experience['max']) && $user_exp > (float)$experience['max']) {
+ return false;
+ }
+ } elseif (is_numeric($experience)) {
+ $user_exp = isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0;
+ if ($user_exp != (float)$experience) {
+ return false;
+ }
+ }
- $search = sanitize_text_field($request->get_param('search'));
- if (!empty($search)) {
- $search_like = '%' . $wpdb->esc_like($search) . '%';
-
- $search_conditions = [
- "about LIKE %s",
- "city LIKE %s",
- "country LIKE %s",
- "profession LIKE %s",
- "skills LIKE %s",
- "interests LIKE %s",
- "company_name LIKE %s"
- ];
-
- $matching_user_ids = $wpdb->get_col($wpdb->prepare("
- SELECT DISTINCT user_id FROM {$wpdb->usermeta}
- WHERE (meta_key = 'first_name' OR meta_key = 'last_name')
- AND meta_value LIKE %s
- ", $search_like));
-
- if (!empty($matching_user_ids)) {
- $placeholders = implode(',', array_fill(0, count($matching_user_ids), '%d'));
- $search_conditions[] = "user_id IN ($placeholders)";
- $query_params = array_merge($query_params, array_fill(0, count($search_conditions) - 1, $search_like), $matching_user_ids);
- } else {
- $query_params = array_merge($query_params, array_fill(0, count($search_conditions), $search_like));
- }
-
- $where_clauses[] = '(' . implode(' OR ', $search_conditions) . ')';
- }
+ // Company name filter
+ if ($company = sanitize_text_field($request->get_param('company_name'))) {
+ if (empty($user_meta['_company_name'][0])) return false;
+ if (strcasecmp($user_meta['_company_name'][0], $company) !== 0) return false;
+ }
- if (get_option('participant_activation') === 'manual') {
- $where_clauses[] = "approve_profile_status = '1'";
- }
+ // Country filter
+ $countries = $request->get_param('country');
+ if (is_array($countries) && !empty($countries)) {
+ if (empty($user_meta['_country'][0])) return false;
+ if (!in_array(strtolower($user_meta['_country'][0]), array_map('strtolower', $countries))) {
+ return false;
+ }
+ } elseif (!empty($countries)) {
+ if (empty($user_meta['_country'][0])) return false;
+ if (strcasecmp($user_meta['_country'][0], $countries) !== 0) return false;
+ }
- $where_sql = $where_clauses ? 'WHERE ' . implode(' AND ', $where_clauses) : '';
- $sql = "SELECT * FROM $table $where_sql";
- $count_sql = "SELECT COUNT(*) FROM $table $where_sql";
+ // City filter
+ if ($city = sanitize_text_field($request->get_param('city'))) {
+ if (empty($user_meta['_city'][0])) return false;
+ if (strcasecmp($user_meta['_city'][0], $city) !== 0) return false;
+ }
- $total = (int) $wpdb->get_var($wpdb->prepare($count_sql, $query_params));
+ // Skills filter
+ $skills = $request->get_param('skills');
+ if (is_array($skills) && !empty($skills)) {
+ if (empty($user_meta['_skills'][0])) return false;
+ $user_skills = maybe_unserialize($user_meta['_skills'][0]);
+ if (!is_array($user_skills)) return false;
+
+ $found = false;
+ foreach ($skills as $skill) {
+ if (in_array($skill, $user_skills)) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) return false;
+ }
- $per_page = max(1, (int) $request->get_param('per_page'));
- $page = max(1, (int) $request->get_param('page'));
- $offset = ($page - 1) * $per_page;
+ // Interests filter
+ $interests = $request->get_param('interests');
+ if (is_array($interests) && !empty($interests)) {
+ if (empty($user_meta['_interests'][0])) return false;
+ $user_interests = maybe_unserialize($user_meta['_interests'][0]);
+ if (!is_array($user_interests)) return false;
+
+ $found = false;
+ foreach ($interests as $interest) {
+ if (in_array($interest, $user_interests)) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) return false;
+ }
- $sql .= $wpdb->prepare(" LIMIT %d OFFSET %d", $per_page, $offset);
- $query_params[] = $per_page;
- $query_params[] = $offset;
+ // Search filter
+ $search = sanitize_text_field($request->get_param('search'));
+ if (!empty($search)) {
+ $found = false;
+
+ // Search in profile fields
+ $profile_fields = ['_about', '_city', '_country', '_profession', '_company_name'];
+ foreach ($profile_fields as $field) {
+ if (!empty($user_meta[$field][0]) && stripos($user_meta[$field][0], $search) !== false) {
+ $found = true;
+ break;
+ }
+ }
+
+ // Search in user name fields
+ if (!$found) {
+ $first_name = get_user_meta($user->ID, 'first_name', true);
+ $last_name = get_user_meta($user->ID, 'last_name', true);
+ if (stripos($first_name, $search) !== false || stripos($last_name, $search) !== false) {
+ $found = true;
+ }
+ }
+
+ if (!$found) return false;
+ }
- $prepared_sql = $wpdb->prepare($sql, $query_params);
- $results = $wpdb->get_results($prepared_sql, ARRAY_A);
+ // Manual approval filter
+ if (get_option('participant_activation') === 'manual') {
+ if (empty($user_meta['_approve_profile_status'][0]) || $user_meta['_approve_profile_status'][0] != '1') {
+ return false;
+ }
+ }
- foreach ($results as &$row) {
- $user_id = $row['user_id'];
- $row['first_name'] = get_user_meta($user_id, 'first_name', true);
- $row['last_name'] = get_user_meta($user_id, 'last_name', true);
- }
+ return true;
+ });
+
+ // Pagination
+ $per_page = max(1, (int) $request->get_param('per_page'));
+ $page = max(1, (int) $request->get_param('page'));
+ $total = count($filtered_users);
+ $offset = ($page - 1) * $per_page;
+ $paginated_users = array_slice($filtered_users, $offset, $per_page);
+
+ // Format results
+ $formatted_results = [];
+ foreach ($paginated_users as $user) {
+ $user_meta = get_user_meta($user->ID);
+ $formatted_results[] = [
+ 'user_id' => $user->ID,
+ 'first_name' => $user_meta['first_name'][0] ?? '',
+ 'last_name' => $user_meta['last_name'][0] ?? '',
+ 'profession' => $user_meta['_profession'][0] ?? '',
+ 'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
+ 'company_name' => $user_meta['_company_name'][0] ?? '',
+ 'country' => $user_meta['_country'][0] ?? '',
+ 'city' => $user_meta['_city'][0] ?? '',
+ 'about' => $user_meta['_about'][0] ?? '',
+ 'skills' => isset($user_meta['_skills'][0]) ? maybe_unserialize($user_meta['_skills'][0]) : [],
+ 'interests' => isset($user_meta['_interests'][0]) ? maybe_unserialize($user_meta['_interests'][0]) : [],
+ 'profile_photo' => $user_meta['_profile_photo'][0] ?? '',
+ 'organization_name' => $user_meta['_organization_name'][0] ?? '',
+ 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : [],
+ ];
+ }
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Users retrieved successfully.',
- 'data' => [
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Users retrieved successfully.',
+ 'data' => [
'total_post_count' => $total,
'current_page' => $page,
'last_page' => ceil($total / $per_page),
'total_pages' => ceil($total / $per_page),
- 'users' => $results,
+ 'users' => $formatted_results,
],
], 200);
- }
-
+ }
}
new WPEM_REST_Filter_Users_Controller();
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 1d63d64..5e586cc 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -60,250 +60,300 @@ public function register_routes() {
}
public function get_attendee_profile($request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response(array(
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ), 403);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response(array(
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ), 403);
+ }
- global $wpdb;
- $attendee_id = $request->get_param('attendeeId');
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ $attendee_id = $request->get_param('attendeeId');
+
+ if ($attendee_id) {
+ // Check if user exists
+ $user = get_user_by('ID', $attendee_id);
+ if (!$user) {
+ return new WP_REST_Response(array(
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'Attendee not found.',
+ 'data' => null
+ ), 404);
+ }
- if ($attendee_id) {
- $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $attendee_id), ARRAY_A);
- if (!$data) {
- return new WP_REST_Response(array(
- 'code' => 404,
- 'status' => 'Not Found',
- 'message' => 'Attendee not found.',
- 'data' => null
- ), 404);
- }
- $profile = $this->format_profile_data($data);
- return new WP_REST_Response(array(
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Profile retrieved successfully.',
- 'data' => $profile
- ), 200);
- } else {
- $results = $wpdb->get_results("SELECT * FROM $table", ARRAY_A);
- $profiles = array_map(array($this, 'format_profile_data'), $results);
- return new WP_REST_Response(array(
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'All profiles retrieved successfully.',
- 'data' => $profiles
- ), 200);
- }
- }
+ // Get all user meta
+ $user_meta = get_user_meta($attendee_id);
+
+ // Format the profile data
+ $profile = array(
+ 'user_id' => $attendee_id,
+ 'display_name' => $user->display_name,
+ 'first_name' => isset($user_meta['first_name'][0]) ? sanitize_text_field($user_meta['first_name'][0]) : '',
+ 'last_name' => isset($user_meta['last_name'][0]) ? sanitize_text_field($user_meta['last_name'][0]) : '',
+ 'email' => $user->user_email,
+ 'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
+ 'profile_photo' => isset($user_meta['_profile_photo'][0]) ? esc_url($user_meta['_profile_photo'][0]) : '',
+ 'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
+ 'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
+ 'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
+ 'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
+ 'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
+ 'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
+ 'skills' => isset($user_meta['_skills'][0]) ? maybe_unserialize($user_meta['_skills'][0]) : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? maybe_unserialize($user_meta['_interests'][0]) : array(),
+ 'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
+ 'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
+ 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
+ 'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
+ 'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
+ 'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : ''
+ );
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Profile retrieved successfully.',
+ 'data' => $profile
+ ), 200);
+ } else {
+ // Get all users with matchmaking profiles
+ $args = array(
+ 'meta_key' => '_matchmaking_profile',
+ 'meta_value' => '1',
+ 'meta_compare' => '='
+ );
+ $users = get_users($args);
+
+ $profiles = array();
+ foreach ($users as $user) {
+ $user_meta = get_user_meta($user->ID);
+ $profiles[] = array(
+ 'user_id' => $user->ID,
+ 'display_name' => $user->display_name,
+ 'first_name' => isset($user_meta['first_name'][0]) ? sanitize_text_field($user_meta['first_name'][0]) : '',
+ 'last_name' => isset($user_meta['last_name'][0]) ? sanitize_text_field($user_meta['last_name'][0]) : '',
+ 'email' => $user->user_email,
+ 'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
+ 'profile_photo' => isset($user_meta['_profile_photo'][0]) ? esc_url($user_meta['_profile_photo'][0]) : '',
+ 'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
+ 'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
+ 'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
+ 'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
+ 'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
+ 'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
+ 'skills' => isset($user_meta['_skills'][0]) ? maybe_unserialize($user_meta['_skills'][0]) : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? maybe_unserialize($user_meta['_interests'][0]) : array(),
+ 'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
+ 'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
+ 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
+ 'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
+ 'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
+ 'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : ''
+ );
+ }
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'All profiles retrieved successfully.',
+ 'data' => $profiles
+ ), 200);
+ }
+ }
/**
* Update profile including handling file upload from device for profile_photo
*/
public function update_attendee_profile($request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.'
- ], 403);
- }
-
- global $wpdb;
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $user_id = $request->get_param('user_id');
-
- $user = get_user_by('id', $user_id);
- if (!$user) {
- return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'User not found.'], 404);
- }
-
- $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
- if (!$existing) {
- return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'Profile not found.'], 404);
- }
-
- $custom_fields = [
- 'profession', 'experience', 'company_name', 'country',
- 'city', 'about', 'skills', 'interests', 'organization_name', 'organization_logo',
- 'organization_city', 'organization_country', 'organization_description',
- 'message_notification', 'approve_profile_status',
- ];
-
- $custom_data = [];
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.'
+ ], 403);
+ }
- // Handle normal fields
- foreach ($custom_fields as $field) {
- if ($request->get_param($field) !== null) {
- $value = $request->get_param($field);
- $custom_data[$field] = sanitize_text_field($value);
- }
- }
+ $user_id = $request->get_param('user_id');
+ $user = get_user_by('id', $user_id);
+
+ if (!$user) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'User not found.'
+ ], 404);
+ }
- // Handle profile_photo file upload if present in $_FILES
- if (!empty($_FILES['profile_photo']) && $_FILES['profile_photo']['error'] === UPLOAD_ERR_OK) {
- require_once ABSPATH . 'wp-admin/includes/file.php';
- $upload_overrides = array('test_form' => false);
+ // List of all meta fields we can update
+ $meta_fields = [
+ '_profession', '_experience', '_company_name', '_country',
+ '_city', '_about', '_skills', '_interests', '_organization_name',
+ '_organization_logo', '_organization_city', '_organization_country',
+ '_organization_description', '_message_notification', '_matchmaking_profile'
+ ];
+
+ // Handle normal meta fields
+ foreach ($meta_fields as $field) {
+ $param_name = str_replace('_', '', $field); // Remove underscore for request param
+ if ($request->get_param($param_name) !== null) {
+ $value = $request->get_param($param_name);
+
+ // Special handling for array fields
+ if (in_array($field, ['_skills', '_interests'])) {
+ $value = maybe_serialize((array)$value);
+ }
+
+ // Special handling for numeric fields
+ if ($field === '_experience') {
+ $value = (float)$value;
+ }
+
+ update_user_meta($user_id, $field, $value);
+ }
+ }
- $movefile = wp_handle_upload($_FILES['profile_photo'], $upload_overrides);
+ // Handle profile_photo file upload
+ if (!empty($_FILES['profile_photo']) && $_FILES['profile_photo']['error'] === UPLOAD_ERR_OK) {
+ require_once ABSPATH . 'wp-admin/includes/file.php';
+ $upload_overrides = ['test_form' => false];
+ $movefile = wp_handle_upload($_FILES['profile_photo'], $upload_overrides);
- if (isset($movefile['url'])) {
- $profile_photo_url = esc_url_raw($movefile['url']);
- $custom_data['profile_photo'] = $profile_photo_url;
- update_user_meta($user_id, '_profile_photo', $profile_photo_url);
- } else {
- return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Profile photo upload failed.'], 500);
- }
- } else {
- // If no file, but profile_photo is sent as URL string, update that
- if ($request->get_param('profile_photo') !== null) {
- $profile_photo_url = esc_url_raw($request->get_param('profile_photo'));
- $custom_data['profile_photo'] = $profile_photo_url;
- update_user_meta($user_id, '_profile_photo', $profile_photo_url);
- }
- }
+ if (isset($movefile['url'])) {
+ update_user_meta($user_id, '_profile_photo', esc_url_raw($movefile['url']));
+
+ } else {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Error',
+ 'message' => 'Profile photo upload failed.'
+ ], 500);
+ }
+ } elseif ($request->get_param('profile_photo')) {
+ update_user_meta($user_id, '_profile_photo', esc_url_raw($request->get_param('profile_photo')));
+
+ }
- // Handle organization_logo file upload if present in $_FILES
+ // Handle organization_logo file upload
if (!empty($_FILES['organization_logo']) && $_FILES['organization_logo']['error'] === UPLOAD_ERR_OK) {
require_once ABSPATH . 'wp-admin/includes/file.php';
- $upload_overrides = array('test_form' => false);
-
+ $upload_overrides = ['test_form' => false];
$movefile = wp_handle_upload($_FILES['organization_logo'], $upload_overrides);
if (isset($movefile['url'])) {
- $organization_logo_url = esc_url_raw($movefile['url']);
- $custom_data['organization_logo'] = $organization_logo_url;
- update_user_meta($user_id, '_organization_logo', $organization_logo_url); // optional
+ update_user_meta($user_id, '_organization_logo', [$movefile['url']]);
} else {
- return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Organization logo upload failed.'], 500);
- }
- } else {
- if ($request->get_param('organization_logo') !== null) {
- $organization_logo_url = esc_url_raw($request->get_param('organization_logo'));
- $custom_data['organization_logo'] = $organization_logo_url;
- update_user_meta($user_id, '_organization_logo', $organization_logo_url); // optional
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Error',
+ 'message' => 'Organization logo upload failed.'
+ ], 500);
}
+ } elseif ($request->get_param('organization_logo')) {
+ update_user_meta($user_id, '_organization_logo', $request->get_param('organization_logo'));
}
-
- if (!empty($custom_data)) {
- $updated = $wpdb->update($table, $custom_data, ['user_id' => $user_id]);
- if ($updated === false) {
- return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Failed to update profile.'], 500);
- }
- }
- // Update basic WP user fields
- if ($first = $request->get_param('first_name')) {
- update_user_meta($user_id, 'first_name', sanitize_text_field($first));
- }
- if ($last = $request->get_param('last_name')) {
- update_user_meta($user_id, 'last_name', sanitize_text_field($last));
- }
- if ($email = $request->get_param('email')) {
- $email = sanitize_email($email);
- $email_exists = email_exists($email);
- if ($email_exists && $email_exists != $user_id) {
- return new WP_REST_Response(['code' => 400, 'status' => 'Error', 'message' => 'Email already in use.'], 400);
- }
- $result = wp_update_user(['ID' => $user_id, 'user_email' => $email]);
- if (is_wp_error($result)) {
- return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => $result->get_error_message()], 500);
- }
- }
+ // Update basic WP user fields
+ if ($request->get_param('first_name')) {
+ update_user_meta($user_id, 'first_name', sanitize_text_field($request->get_param('first_name')));
+ }
+
+ if ($request->get_param('last_name')) {
+ update_user_meta($user_id, 'last_name', sanitize_text_field($request->get_param('last_name')));
+ }
+
+ if ($request->get_param('email')) {
+ $email = sanitize_email($request->get_param('email'));
+ $email_exists = email_exists($email);
+
+ if ($email_exists && $email_exists != $user_id) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Error',
+ 'message' => 'Email already in use.'
+ ], 400);
+ }
+
+ $result = wp_update_user([
+ 'ID' => $user_id,
+ 'user_email' => $email
+ ]);
+
+ if (is_wp_error($result)) {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Error',
+ 'message' => $result->get_error_message()
+ ], 500);
+ }
+ }
- return new WP_REST_Response(['code' => 200, 'status' => 'OK', 'message' => 'Profile updated successfully.'], 200);
- }
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Profile updated successfully.'
+ ], 200);
+ }
public function upload_user_file($request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.'
- ], 403);
- }
-
- $user_id = $request->get_param('user_id');
- $user = get_user_by('id', $user_id);
- if (!$user) {
- return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'User not found.'], 404);
- }
-
- if (empty($_FILES['file'])) {
- return new WP_REST_Response(['code' => 400, 'status' => 'Error', 'message' => 'No file uploaded.'], 400);
- }
-
- require_once ABSPATH . 'wp-admin/includes/file.php';
-
- $file = $_FILES['file'];
- $upload_overrides = array('test_form' => false);
-
- $movefile = wp_handle_upload($file, $upload_overrides);
-
- if (!isset($movefile['url'])) {
- return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'File upload failed.'], 500);
- }
-
- $file_url = esc_url_raw($movefile['url']);
-
- global $wpdb;
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.'
+ ], 403);
+ }
- $existing = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id));
- if (!$existing) {
- return new WP_REST_Response(['code' => 404, 'status' => 'Not Found', 'message' => 'Profile not found.'], 404);
- }
+ $user_id = $request->get_param('user_id');
+ $user = get_user_by('id', $user_id);
+
+ if (!$user) {
+ return new WP_REST_Response([
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'User not found.'
+ ], 404);
+ }
- $updated = $wpdb->update(
- $table,
- ['profile_photo' => $file_url],
- ['user_id' => $user_id]
- );
+ if (empty($_FILES['file'])) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Error',
+ 'message' => 'No file uploaded.'
+ ], 400);
+ }
- if ($updated === false) {
- return new WP_REST_Response(['code' => 500, 'status' => 'Error', 'message' => 'Failed to update file URL in table.'], 500);
- }
+ require_once ABSPATH . 'wp-admin/includes/file.php';
+
+ $file = $_FILES['file'];
+ $upload_overrides = ['test_form' => false];
+ $movefile = wp_handle_upload($file, $upload_overrides);
+
+ if (!isset($movefile['url'])) {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Error',
+ 'message' => 'File upload failed.'
+ ], 500);
+ }
- update_user_meta($user_id, '_profile_photo', $file_url);
+ $file_url = esc_url_raw($movefile['url']);
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'File uploaded and stored successfully.',
- 'data' => ['file_url' => $file_url]
- ], 200);
- }
+ // Update both profile photo meta fields
+ update_user_meta($user_id, '_profile_photo', $file_url);
+
- private function format_profile_data($data) {
- $user = get_userdata($data['user_id']);
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'File uploaded and stored successfully.',
+ 'data' => [
+ 'file_url' => $file_url,
+ 'meta_updated' => true
+ ]
+ ], 200);
+ }
- return array(
- 'attendeeId' => $data['user_id'],
- 'firstName' => $user ? get_user_meta($user->ID, 'first_name', true) : '',
- 'lastName' => $user ? get_user_meta($user->ID, 'last_name', true) : '',
- 'email' => $user ? $user->user_email : '',
- 'profilePhoto' => $data['profile_photo'],
- 'profession' => $data['profession'],
- 'experience' => $data['experience'],
- 'companyName' => $data['company_name'],
- 'country' => $data['country'],
- 'city' => $data['city'],
- 'about' => $data['about'],
- 'skills' => maybe_unserialize($data['skills']),
- 'interests' => maybe_unserialize($data['interests']),
- 'organizationName' => $data['organization_name'],
- 'organizationLogo' => $data['organization_logo'],
- 'organizationCity' => $data['organization_city'],
- 'organizationCountry' => $data['organization_country'],
- 'organizationDescription' => $data['organization_description'],
- 'messageNotification' => $data['message_notification'],
- 'approveProfileStatus' => $data['approve_profile_status'],
- );
- }
}
new WPEM_REST_Attendee_Profile_Controller_All();
From ec37191793c785bc9905441e2e014a2f63af7424 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 29 Jul 2025 09:48:49 +0530
Subject: [PATCH 088/171] #182 Changes in Match making APIs due to changes in
database table changes
---
includes/wpem-rest-authentication.php | 108 +-
.../wpem-rest-matchmaking-create-meetings.php | 1229 ++++++++---------
.../wpem-rest-matchmaking-user-messages.php | 50 +-
3 files changed, 667 insertions(+), 720 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index 148c052..eb0515a 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -671,12 +671,13 @@ public function perform_login_authentication($request){
*
* @since 1.0.0
*/
- public function perform_user_authentication($request){
+ public function perform_user_authentication($request) {
$params = $request->get_json_params();
$username = isset($params['username']) ? trim($params['username']) : '';
$password = isset($params['password']) ? $params['password'] : '';
$response = array();
- if( !empty( $username ) && !empty($password)){
+
+ if (!empty($username) && !empty($password)) {
$user = wp_authenticate($username, $password);
if (is_wp_error($user)) {
return parent::prepare_error_for_response(401);
@@ -689,85 +690,90 @@ public function perform_user_authentication($request){
$is_matchmaking = get_user_meta($user_id, '_matchmaking_profile', true);
$enable_matchmaking = get_option('enable_matchmaking', false) ? 1 : 0;
- $all_mobile_pages = array( 'dashboard', 'attendees', 'guest_list', 'orders', 'arrivals' );
+ $all_mobile_pages = array('dashboard', 'attendees', 'guest_list', 'orders', 'arrivals');
$user_mobile_menu = get_user_meta($user_id, '_mobile_menu', true);
$user_mobile_menu = is_array($user_mobile_menu) ? $user_mobile_menu : [];
$mobile_menu_status = array();
- foreach ( $all_mobile_pages as $page ) {
- $mobile_menu_status[ $page ] = in_array( $page, $user_mobile_menu ) ? 1 : 0;
+ foreach ($all_mobile_pages as $page) {
+ $mobile_menu_status[$page] = in_array($page, $user_mobile_menu) ? 1 : 0;
}
+ // Get all user data from meta
+ $user_email = get_user_meta($user_id, 'user_email', true);
+ $first_name = get_user_meta($user_id, 'first_name', true);
+ $last_name = get_user_meta($user_id, 'last_name', true);
+ $user_login = get_user_meta($user_id, 'user_login', true);
+
$data = array(
'token' => $token,
'user' => array(
'user_id' => $user_id,
- 'user_email' => $user->user_email,
- 'first_name' => $user->first_name,
- 'last_name' => $user->last_name,
- 'username' => $user->user_login,
- 'matchmaking_profile' => $is_matchmaking,
+ 'user_email' => $user_email,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
+ 'username' => $user_login,
+ 'matchmaking_profile' => $is_matchmaking,
'enable_matchmaking' => $enable_matchmaking,
'mobile_menu' => $mobile_menu_status,
- )
+ )
);
- if ($is_matchmaking && $enable_matchmaking ) {
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
- $matchmaking_data = $wpdb->get_row(
- $wpdb->prepare("SELECT * FROM $table WHERE user_id = %d", $user_id),
- ARRAY_A
+
+ if ($is_matchmaking && $enable_matchmaking) {
+ // Get matchmaking data from user meta instead of custom table
+ $matchmaking_details = array(
+ 'attendeeId' => $user_id,
+ 'firstName' => $first_name,
+ 'lastName' => $last_name,
+ 'email' => $user_email,
+ 'profilePhoto' => get_user_meta($user_id, '_profile_photo', true) ?: '',
+ 'profession' => get_user_meta($user_id, '_profession', true) ?: '',
+ 'experience' => get_user_meta($user_id, '_experience', true) ?: '',
+ 'companyName' => get_user_meta($user_id, '_company_name', true) ?: '',
+ 'country' => get_user_meta($user_id, '_country', true) ?: '',
+ 'city' => get_user_meta($user_id, '_city', true) ?: '',
+ 'about' => get_user_meta($user_id, '_about', true) ?: '',
+ 'skills' => maybe_unserialize(get_user_meta($user_id, '
+ _skills', true)) ?: [],
+ 'interests' => maybe_unserialize(get_user_meta($user_id, '_interests', true)) ?: [],
+ 'organizationName' => get_user_meta($user_id, '_organization_name', true) ?: '',
+ 'organizationLogo' => get_user_meta($user_id, '_organization_logo', true) ?: '',
+ 'organizationCity' => get_user_meta($user_id, '_organization_city', true) ?: '',
+ 'organizationCountry' => get_user_meta($user_id, '_organization_country', true) ?: '',
+ 'organizationDescription' => get_user_meta($user_id, 'organization_description', true) ?: '',
+ 'messageNotification' => get_user_meta($user_id, '_message_notification', true) ?: '',
+ 'approveProfileStatus' => get_user_meta($user_id, '_approve_profile_status', true) ?: '',
);
- if ($matchmaking_data) {
- $data['user']['matchmaking_details'] = array(
- 'attendeeId' => $matchmaking_data['user_id'],
- 'firstName' => get_user_meta($user_id, 'first_name', true),
- 'lastName' => get_user_meta($user_id, 'last_name', true),
- 'email' => $user->user_email,
- 'profilePhoto' => $matchmaking_data['profile_photo'] ?? '',
- 'profession' => $matchmaking_data['profession'] ?? '',
- 'experience' => $matchmaking_data['experience'] ?? '',
- 'companyName' => $matchmaking_data['company_name'] ?? '',
- 'country' => $matchmaking_data['country'] ?? '',
- 'city' => $matchmaking_data['city'] ?? '',
- 'about' => $matchmaking_data['about'] ?? '',
- 'skills' => !empty($matchmaking_data['skills']) ? maybe_unserialize($matchmaking_data['skills']) : [],
- 'interests' => !empty($matchmaking_data['interests']) ? maybe_unserialize($matchmaking_data['interests']) : [],
- 'organizationName' => $matchmaking_data['organization_name'] ?? '',
- 'organizationLogo' => $matchmaking_data['organization_logo'] ?? '',
- 'organizationCity' => $matchmaking_data['organization_city'] ?? '',
- 'organizationCountry' => $matchmaking_data['organization_country'] ?? '',
- 'organizationDescription' => $matchmaking_data['organization_description'] ?? '',
- 'messageNotification' => $matchmaking_data['message_notification'] ?? '',
- 'approveProfileStatus' => $matchmaking_data['approve_profile_status'] ?? '',
- );
- }
+ $data['user']['matchmaking_details'] = $matchmaking_details;
}
+
+ // Keep the API key check logic unchanged
$key_data = $wpdb->get_row(
$wpdb->prepare(
- "
- SELECT *
- FROM {$wpdb->prefix}wpem_rest_api_keys
- WHERE user_id = %s
- ",
+ "SELECT * FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %s",
$user_id
)
);
- if( !empty( $key_data ) ) {
- if( !empty($key_data->date_expires ) && strtotime( $key_data->date_expires ) >= strtotime( date('Y-m-d H:i:s') ) ){
- $key_data->expiry = false;
+
+ if (!empty($key_data)) {
+ if (!empty($key_data->date_expires) && strtotime($key_data->date_expires) >= strtotime(date('Y-m-d H:i:s'))) {
+ $key_data->expiry = false;
} else {
- $key_data->expiry = true;
+ $key_data->expiry = true;
}
$data['organizer_info'] = $key_data;
}
- if( empty( $key_data ) && !get_user_meta($user_id, '_matchmaking_profile', true))
+
+ if (empty($key_data) && !get_user_meta($user_id, '_matchmaking_profile', true)) {
return parent::prepare_error_for_response(405);
+ }
+
$response_data = parent::prepare_error_for_response(200);
$response_data['data'] = $data;
return $response_data;
}
- } else{
+ } else {
return parent::prepare_error_for_response(400);
}
}
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 8081578..e15d89b 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -115,173 +115,160 @@ public function register_routes() {
'permission_callback' => '__return_true', // if no auth needed
]);
}
- public function create_meeting(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
-
- global $wpdb;
-
- $user_id = intval($request->get_param('user_id'));
- $event_id = intval($request->get_param('event_id'));
- $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
- $slot = sanitize_text_field($request->get_param('slot'));
- $participants = $request->get_param('meeting_participants');
- $message = sanitize_textarea_field($request->get_param('write_a_message'));
-
- if (
- !$user_id || !get_userdata($user_id) ||
- empty($meeting_date) || empty($slot) ||
- empty($participants) || !is_array($participants)
- ) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'Bad Request',
- 'message' => 'Missing or invalid parameters.',
- 'data' => []
- ], 400);
- }
-
- // Filter out the user themselves from participant list
- $participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
- $participants = array_fill_keys($participants, -1); // -1 = pending
-
- $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $inserted = $wpdb->insert($table, [
- 'user_id' => $user_id,
- 'event_id' => $event_id,
- 'participant_ids' => serialize($participants),
- 'meeting_date' => $meeting_date,
- 'meeting_start_time' => $slot,
- 'meeting_end_time' => date("H:i", strtotime($slot . " +1 hour")),
- 'message' => $message,
- 'meeting_status' => 0
- ], ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']);
-
- if (!$inserted) {
- return new WP_REST_Response([
- 'code' => 500,
- 'status' => 'Internal Server Error',
- 'message' => 'Could not create meeting.',
- 'data' => []
- ], 500);
- }
-
- $meeting_id = $wpdb->insert_id;
- $formatted_date = date("l, d F Y", strtotime($meeting_date));
- $formatted_time = date("h:i A", strtotime($slot));
- $sender_user = get_userdata($user_id);
-
- $participant_details = [];
-
- if (!empty($participants)) {
- $profile_table = $wpdb->prefix . 'wpem_matchmaking_users';
- $placeholders = implode(',', array_fill(0, count($participants), '%d'));
- $query = $wpdb->prepare("SELECT * FROM $profile_table WHERE user_id IN ($placeholders)", ...array_keys($participants));
- $results = $wpdb->get_results($query, ARRAY_A);
-
- foreach ($results as $participant) {
- $participant_user = get_userdata($participant['user_id']);
- $participant_name = $participant_user->display_name ?? 'User';
- $participant_email = $participant_user->user_email ?? '';
- $profile_picture = $participant['profile_photo'] ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
-
- $participant_details[] = [
- 'name' => $participant_name,
- 'profession' => $participant['profession'] ?? '',
- 'profile_picture' => esc_url($profile_picture)
- ];
-
- // Email to participant
- $host_profile = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d", $user_id), ARRAY_A);
- $host_company = $host_profile['company_name'] ?? '';
- $host_city = $host_profile['city'] ?? '';
- $all_countries = wpem_registration_get_all_countries();
- $host_country = $all_countries[$host_profile['country']] ?? '';
- $event_name = get_the_title($event_id) ?: '';
- $timezone_abbr = wp_timezone_string();
-
- $subject = "{$sender_user->display_name} requested a meeting with you";
- $body = "
- Hello {$participant_name},
- {$sender_user->display_name} has requested a meeting with you.
- Event: {$event_name}
- Date: {$formatted_date}
- Time: {$formatted_time} {$timezone_abbr}
- Company: {$host_company}
- City: {$host_city}
- Country: {$host_country}
- Message: {$message}
- ";
-
- wp_mail($participant_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
- }
- }
-
- // Email to sender
- $participant_names = implode(', ', array_column($participant_details, 'name'));
- wp_mail(
- $sender_user->user_email,
- 'Your Meeting Request Has Been Sent',
- "
- Hello {$sender_user->display_name},
- Your meeting request has been sent to: {$participant_names} .
- Date: {$formatted_date}
- Time: {$formatted_time}
- Message: {$message}
- ",
- ['Content-Type: text/html; charset=UTF-8']
- );
- // Update booked slot (2) for the host only
- $availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
-
- $serialized = $wpdb->get_var($wpdb->prepare(
- "SELECT meeting_availability_slot FROM $availability_table WHERE user_id = %d",
- $user_id
- ));
-
- $slot_data = maybe_unserialize($serialized);
- if (!is_array($slot_data)) {
- $slot_data = [];
- }
-
- if (!isset($slot_data[$event_id])) {
- $slot_data[$event_id] = [];
- }
- if (!isset($slot_data[$event_id][$meeting_date])) {
- $slot_data[$event_id][$meeting_date] = [];
- }
-
- // Set slot as 2 (booked)
- $slot_data[$event_id][$meeting_date][$slot] = 2;
-
- // Update DB for host only
- $wpdb->update(
- $availability_table,
- ['meeting_availability_slot' => maybe_serialize($slot_data)],
- ['user_id' => $user_id],
- ['%s'],
- ['%d']
- );
-
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Meeting created and emails sent!',
- 'data' => [
- 'meeting_date' => $formatted_date,
- 'time' => $formatted_time,
- 'participants' => $participant_details,
- 'message' => $message
- ]
- ], 200);
- }
- public function get_user_meetings(WP_REST_Request $request) {
+ public function create_meeting(WP_REST_Request $request) {
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+
+ global $wpdb;
+
+ $user_id = intval($request->get_param('user_id'));
+ $event_id = intval($request->get_param('event_id'));
+ $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
+ $slot = sanitize_text_field($request->get_param('slot'));
+ $participants = $request->get_param('meeting_participants');
+ $message = sanitize_textarea_field($request->get_param('write_a_message'));
+
+ if (
+ !$user_id || !get_userdata($user_id) ||
+ empty($meeting_date) || empty($slot) ||
+ empty($participants) || !is_array($participants)
+ ) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'Missing or invalid parameters.',
+ 'data' => []
+ ], 400);
+ }
+
+ // Filter out the user themselves from participant list
+ $participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
+ $participants = array_fill_keys($participants, -1); // -1 = pending
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $inserted = $wpdb->insert($table, [
+ 'user_id' => $user_id,
+ 'event_id' => $event_id,
+ 'participant_ids' => serialize($participants),
+ 'meeting_date' => $meeting_date,
+ 'meeting_start_time' => $slot,
+ 'meeting_end_time' => date("H:i", strtotime($slot . " +1 hour")),
+ 'message' => $message,
+ 'meeting_status' => 0
+ ], ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']);
+
+ if (!$inserted) {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Internal Server Error',
+ 'message' => 'Could not create meeting.',
+ 'data' => []
+ ], 500);
+ }
+
+ $meeting_id = $wpdb->insert_id;
+ $formatted_date = date("l, d F Y", strtotime($meeting_date));
+ $formatted_time = date("h:i A", strtotime($slot));
+ $sender_user = get_userdata($user_id);
+
+ $participant_details = [];
+
+ if (!empty($participants)) {
+ foreach (array_keys($participants) as $participant_id) {
+ $participant_user = get_userdata($participant_id);
+ if (!$participant_user) continue;
+
+ $participant_meta = get_user_meta($participant_id);
+
+ $participant_name = $participant_user->display_name ?? 'User';
+ $participant_email = $participant_user->user_email ?? '';
+ $profile_picture = $participant_meta['_profile_photo'][0] ?? EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
+
+ $participant_details[] = [
+ 'name' => $participant_name,
+ 'profession' => $participant_meta['_profession'][0] ?? '',
+ 'profile_picture' => esc_url($profile_picture)
+ ];
+
+ // Email to participant
+ $host_meta = get_user_meta($user_id);
+ $host_company = $host_meta['_company_name'][0] ?? '';
+ $host_city = $host_meta['_city'][0] ?? '';
+ $all_countries = wpem_get_all_countries();
+ $host_country = $all_countries[$host_meta['_country'][0]] ?? '';
+ $event_name = get_the_title($event_id) ?: '';
+ $timezone_abbr = wp_timezone_string();
+
+ $subject = "{$sender_user->display_name} requested a meeting with you";
+ $body = "
+ Hello {$participant_name},
+ {$sender_user->display_name} has requested a meeting with you.
+ Event: {$event_name}
+ Date: {$formatted_date}
+ Time: {$formatted_time} {$timezone_abbr}
+ Company: {$host_company}
+ City: {$host_city}
+ Country: {$host_country}
+ Message: {$message}
+ ";
+
+ wp_mail($participant_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
+ }
+ }
+
+ // Email to sender
+ $participant_names = implode(', ', array_column($participant_details, 'name'));
+ wp_mail(
+ $sender_user->user_email,
+ 'Your Meeting Request Has Been Sent',
+ "
+ Hello {$sender_user->display_name},
+ Your meeting request has been sent to: {$participant_names} .
+ Date: {$formatted_date}
+ Time: {$formatted_time}
+ Message: {$message}
+ ",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
+
+ // Update booked slot (2) for the host only
+ $slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+ if (!is_array($slot_data)) {
+ $slot_data = [];
+ }
+
+ if (!isset($slot_data[$event_id])) {
+ $slot_data[$event_id] = [];
+ }
+ if (!isset($slot_data[$event_id][$meeting_date])) {
+ $slot_data[$event_id][$meeting_date] = [];
+ }
+
+ // Set slot as 2 (booked)
+ $slot_data[$event_id][$meeting_date][$slot] = 2;
+
+ // Update user meta for host only
+ update_user_meta($user_id, '_meeting_availability_slot', $slot_data);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meeting created and emails sent!',
+ 'data' => [
+ 'meeting_date' => $formatted_date,
+ 'time' => $formatted_time,
+ 'participants' => $participant_details,
+ 'message' => $message
+ ]
+ ], 200);
+ }
+ public function get_user_meetings(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
'code' => 403,
@@ -334,39 +321,51 @@ public function get_user_meetings(WP_REST_Request $request) {
$participants_info = [];
foreach ($participant_statuses as $pid => $status) {
- //if ((int)$pid === $user_id) continue;
-
- $user_data = get_userdata($pid);
- $display_name = $user_data ? $user_data->display_name : '';
+ // Get all user data from user meta
+ $display_name = get_user_meta($pid, 'display_name', true);
+ if (empty($display_name)) {
+ $first_name = get_user_meta($pid, 'first_name', true);
+ $last_name = get_user_meta($pid, 'last_name', true);
+ $display_name = trim("$first_name $last_name");
+ }
- $meta = $wpdb->get_row($wpdb->prepare(
- "SELECT profile_photo, profession, company_name FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d",
- $pid
- ));
+ // Get profile data from user meta (assuming these are stored as meta)
+ $profile_photo = get_user_meta($pid, '_profile_photo', true);
+ $profession = get_user_meta($pid, '_profession', true); // Note: Typo in 'profession'?
+ $company_name = get_user_meta($pid, '_company_name', true);
$participants_info[] = [
'id' => (int)$pid,
'status' => (int)$status,
'name' => $display_name,
- 'image' => !empty($meta->profile_photo) ? esc_url($meta->profile_photo) : '',
- 'profession' => isset($meta->profession) ? esc_html($meta->profession) : '',
- 'company' => isset($meta->company_name) ? esc_html($meta->company_name) : '',
+ 'image' => !empty($profile_photo) ? esc_url($profile_photo) : '',
+ 'profession' => !empty($profession) ? esc_html($profession) : '',
+ 'company' => !empty($company_name) ? esc_html($company_name) : '',
];
}
+
$host_id = (int)$meeting['user_id'];
- $host_user = get_userdata($host_id);
- $host_meta = $wpdb->get_row($wpdb->prepare(
- "SELECT profile_photo, profession, company_name FROM {$wpdb->prefix}wpem_matchmaking_users WHERE user_id = %d",
- $host_id
- ));
+ // Get host data from user meta
+ $host_display_name = get_user_meta($host_id, 'display_name', true);
+ if (empty($host_display_name)) {
+ $first_name = get_user_meta($host_id, 'first_name', true);
+ $last_name = get_user_meta($host_id, 'last_name', true);
+ $host_display_name = trim("$first_name $last_name");
+ }
+
+ // Get host profile data from user meta
+ $host_profile_photo = get_user_meta($host_id, '_profile_photo', true);
+ $host_profession = get_user_meta($host_id, '_profession', true);
+ $host_company_name = get_user_meta($host_id, '_company_name', true);
$host_info = [
'id' => $host_id,
- 'name' => $host_user ? $host_user->display_name : '',
- 'image' => !empty($host_meta->profile_photo) ? esc_url($host_meta->profile_photo) : '',
- 'profession' => isset($host_meta->profession) ? esc_html($host_meta->profession) : '',
- 'company' => isset($host_meta->company_name) ? esc_html($host_meta->company_name) : '',
+ 'name' => $host_display_name,
+ 'image' => !empty($host_profile_photo) ? esc_url($host_profile_photo) : '',
+ 'profession' => !empty($host_profession) ? esc_html($host_profession) : '',
+ 'company' => !empty($host_company_name) ? esc_html($host_company_name) : '',
];
+
$meeting_data[] = [
'meeting_id' => (int)$meeting['id'],
'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
@@ -396,479 +395,395 @@ public function get_user_meetings(WP_REST_Request $request) {
], 200);
}
public function cancel_meeting(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
-
- global $wpdb;
-
- $meeting_id = intval($request->get_param('meeting_id'));
- $user_id = intval($request->get_param('user_id'));
-
- if (!$meeting_id || !$user_id) {
- return new WP_REST_Response(['code' => 400, 'status' => 'error', 'message' => 'Missing meeting_id or user_id.'], 400);
- }
-
- $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $meeting = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE id = %d", $meeting_id), ARRAY_A);
-
- if (!$meeting) {
- return new WP_REST_Response(['code' => 404, 'status' => 'error', 'message' => 'Meeting not found.'], 404);
- }
-
- if ((int)$meeting['user_id'] !== $user_id) {
- return new WP_REST_Response(['code' => 403, 'status' => 'error', 'message' => 'Only the host can cancel the meeting.'], 403);
- }
-
- $updated = $wpdb->update($table, ['meeting_status' => -1], ['id' => $meeting_id], ['%d'], ['%d']);
-
- if (!$updated) {
- return new WP_REST_Response(['code' => 500, 'status' => 'error', 'message' => 'Failed to cancel meeting.'], 500);
- }
-
- // Participant + host IDs
- $participant_ids = maybe_unserialize($meeting['participant_ids']);
- if (!is_array($participant_ids)) $participant_ids = [];
- $participant_ids = array_keys($participant_ids);
- $participant_ids[] = (int)$meeting['user_id'];
- $participant_ids = array_unique($participant_ids);
-
- // === Availability reset ===
- $event_id = (int)$meeting['event_id'];
- $meeting_date = $meeting['meeting_date'];
- $start_time = date('H:i', strtotime($meeting['meeting_start_time'])); // convert from H:i:s to H:i
-
- $profile_table = $wpdb->prefix . 'wpem_matchmaking_users';
-
- foreach ($participant_ids as $pid) {
- $current_slots_serialized = $wpdb->get_var($wpdb->prepare(
- "SELECT meeting_availability_slot FROM $profile_table WHERE user_id = %d",
- $pid
- ));
-
- $current_slots = maybe_unserialize($current_slots_serialized);
- if (!is_array($current_slots)) $current_slots = [];
-
- if (!isset($current_slots[$event_id])) $current_slots[$event_id] = [];
- if (!isset($current_slots[$event_id][$meeting_date])) $current_slots[$event_id][$meeting_date] = [];
-
- if (isset($current_slots[$event_id][$meeting_date][$start_time]) && $current_slots[$event_id][$meeting_date][$start_time] == 2) {
- $current_slots[$event_id][$meeting_date][$start_time] = 1;
-
- $wpdb->update(
- $profile_table,
- ['meeting_availability_slot' => maybe_serialize($current_slots)],
- ['user_id' => $pid],
- ['%s'],
- ['%d']
- );
- }
- }
-
- // Notify participants
- foreach ($participant_ids as $pid) {
- if ($pid == $user_id) continue;
-
- $user = get_userdata($pid);
- if ($user) {
- wp_mail(
- $user->user_email,
- 'Meeting Cancelled',
- "Hello {$user->display_name},
- The meeting scheduled on {$meeting_date} has been cancelled .
",
- ['Content-Type: text/html; charset=UTF-8']
- );
- }
- }
-
- // Notify host
- $host = get_userdata($user_id);
- if ($host) {
- wp_mail(
- $host->user_email,
- 'You Cancelled a Meeting',
- "Hello {$host->display_name},
- You have cancelled the meeting scheduled on {$meeting_date} .
",
- ['Content-Type: text/html; charset=UTF-8']
- );
- }
-
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Meeting cancelled successfully.',
- 'data' => ['meeting_id' => $meeting_id],
- ], 200);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+
+ global $wpdb;
+
+ $meeting_id = intval($request->get_param('meeting_id'));
+ $user_id = intval($request->get_param('user_id'));
+
+ if (!$meeting_id || !$user_id) {
+ return new WP_REST_Response(['code' => 400, 'status' => 'error', 'message' => 'Missing meeting_id or user_id.'], 400);
+ }
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $meeting = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE id = %d", $meeting_id), ARRAY_A);
+
+ if (!$meeting) {
+ return new WP_REST_Response(['code' => 404, 'status' => 'error', 'message' => 'Meeting not found.'], 404);
+ }
+
+ if ((int)$meeting['user_id'] !== $user_id) {
+ return new WP_REST_Response(['code' => 403, 'status' => 'error', 'message' => 'Only the host can cancel the meeting.'], 403);
+ }
+
+ $updated = $wpdb->update($table, ['meeting_status' => -1], ['id' => $meeting_id], ['%d'], ['%d']);
+
+ if (!$updated) {
+ return new WP_REST_Response(['code' => 500, 'status' => 'error', 'message' => 'Failed to cancel meeting.'], 500);
+ }
+
+ // Participant + host IDs
+ $participant_ids = maybe_unserialize($meeting['participant_ids']);
+ if (!is_array($participant_ids)) $participant_ids = [];
+ $participant_ids = array_keys($participant_ids);
+ $participant_ids[] = (int)$meeting['user_id'];
+ $participant_ids = array_unique($participant_ids);
+
+ // === Availability reset ===
+ $event_id = (int)$meeting['event_id'];
+ $meeting_date = $meeting['meeting_date'];
+ $start_time = date('H:i', strtotime($meeting['meeting_start_time']));
+
+ foreach ($participant_ids as $pid) {
+ $slot_data = maybe_unserialize(get_user_meta($pid, '_meeting_availability_slot', true));
+ if (!is_array($slot_data)) {
+ $slot_data = [];
+ }
+
+ if (!isset($slot_data[$event_id])) $slot_data[$event_id] = [];
+ if (!isset($slot_data[$event_id][$meeting_date])) $slot_data[$event_id][$meeting_date] = [];
+
+ if (isset($slot_data[$event_id][$meeting_date][$start_time]) && $slot_data[$event_id][$meeting_date][$start_time] == 2) {
+ $slot_data[$event_id][$meeting_date][$start_time] = 1;
+ update_user_meta($pid, '_meeting_availability_slot', $slot_data);
+ }
+ }
+
+ // Notify participants
+ foreach ($participant_ids as $pid) {
+ if ($pid == $user_id) continue;
+
+ $user = get_userdata($pid);
+ if ($user) {
+ wp_mail(
+ $user->user_email,
+ 'Meeting Cancelled',
+ "Hello {$user->display_name},
+ The meeting scheduled on {$meeting_date} has been cancelled .
",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
+ }
+ }
+
+ // Notify host
+ $host = get_userdata($user_id);
+ if ($host) {
+ wp_mail(
+ $host->user_email,
+ 'You Cancelled a Meeting',
+ "Hello {$host->display_name},
+ You have cancelled the meeting scheduled on {$meeting_date} .
",
+ ['Content-Type: text/html; charset=UTF-8']
+ );
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meeting cancelled successfully.',
+ 'data' => ['meeting_id' => $meeting_id],
+ ], 200);
+ }
public function update_meeting_status(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
-
- global $wpdb;
-
- $meeting_id = intval($request->get_param('meeting_id'));
- $user_id = intval($request->get_param('user_id'));
- $new_status = intval($request->get_param('status'));
-
- if (!$meeting_id || !$user_id || !in_array($new_status, [0, 1], true)) {
- return new WP_REST_Response(['code' => 400, 'message' => 'Invalid parameters.'], 400);
- }
-
- $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
-
- $meeting = $wpdb->get_row($wpdb->prepare("
- SELECT participant_ids, event_id, meeting_date, meeting_start_time
- FROM $table
- WHERE id = %d", $meeting_id
- ));
-
- if (!$meeting) {
- return new WP_REST_Response(['code' => 404, 'message' => 'Meeting not found.'], 404);
- }
-
- $participant_data = maybe_unserialize($meeting->participant_ids);
- if (!is_array($participant_data)) {
- $participant_data = [];
- }
-
- if (!array_key_exists($user_id, $participant_data)) {
- return new WP_REST_Response(['code' => 403, 'message' => 'You are not a participant of this meeting.'], 403);
- }
-
- // If user is accepting, check for conflict in same slot
- if ($new_status === 1) {
- $event_id = $meeting->event_id;
- $meeting_date = $meeting->meeting_date;
- $slot = date('H:i', strtotime($meeting->meeting_start_time));
-
- $conflicting_meeting = $wpdb->get_row($wpdb->prepare("
- SELECT id FROM $table
- WHERE id != %d
- AND event_id = %d
- AND meeting_date = %s
- AND meeting_start_time = %s
- AND meeting_status != -1
- ", $meeting_id, $event_id, $meeting_date, $meeting->meeting_start_time));
-
- if ($conflicting_meeting) {
- $existing_participants = $wpdb->get_var($wpdb->prepare("
- SELECT participant_ids FROM $table WHERE id = %d
- ", $conflicting_meeting->id));
-
- $existing_participant_data = maybe_unserialize($existing_participants);
- if (is_array($existing_participant_data) && isset($existing_participant_data[$user_id]) && $existing_participant_data[$user_id] == 1) {
- return new WP_REST_Response([
- 'code' => 409,
- 'message' => 'You already have a confirmed meeting scheduled at this time slot.',
- ], 409);
- }
- }
- }
-
- // Update this user's status
- $participant_data[$user_id] = $new_status;
-
- // Determine overall meeting status
- $meeting_status = (in_array(1, $participant_data, true)) ? 1 : 0;
-
- // Update meeting record
- $updated = $wpdb->update(
- $table,
- [
- 'participant_ids' => maybe_serialize($participant_data),
- 'meeting_status' => $meeting_status,
- ],
- ['id' => $meeting_id],
- ['%s', '%d'],
- ['%d']
- );
-
- if ($updated === false) {
- return new WP_REST_Response(['code' => 500, 'message' => 'Failed to update meeting status.'], 500);
- }
-
- // Update availability slot for this user
- $availability_table = $wpdb->prefix . 'wpem_matchmaking_users';
-
- $serialized = $wpdb->get_var($wpdb->prepare(
- "SELECT meeting_availability_slot FROM $availability_table WHERE user_id = %d",
- $user_id
- ));
-
- $slot_data = maybe_unserialize($serialized);
- if (!is_array($slot_data)) {
- $slot_data = [];
- }
-
- if (!isset($slot_data[$event_id])) {
- $slot_data[$event_id] = [];
- }
- if (!isset($slot_data[$event_id][$meeting_date])) {
- $slot_data[$event_id][$meeting_date] = [];
- }
-
- $slot_data[$event_id][$meeting_date][date('H:i', strtotime($meeting->meeting_start_time))] = ($new_status === 1) ? 2 : 1;
-
- $wpdb->update(
- $availability_table,
- ['meeting_availability_slot' => maybe_serialize($slot_data)],
- ['user_id' => $user_id],
- ['%s'],
- ['%d']
- );
-
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => $new_status ? 'Meeting accepted.' : 'Meeting declined.',
- 'data' => [
- 'meeting_id' => $meeting_id,
- 'participant_id' => $user_id,
- 'participant_status' => $new_status,
- 'meeting_status' => $meeting_status,
- ]
- ], 200);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+
+ global $wpdb;
+
+ $meeting_id = intval($request->get_param('meeting_id'));
+ $user_id = intval($request->get_param('user_id'));
+ $new_status = intval($request->get_param('status'));
+
+ if (!$meeting_id || !$user_id || !in_array($new_status, [0, 1], true)) {
+ return new WP_REST_Response(['code' => 400, 'message' => 'Invalid parameters.'], 400);
+ }
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+
+ $meeting = $wpdb->get_row($wpdb->prepare("
+ SELECT participant_ids, event_id, meeting_date, meeting_start_time
+ FROM $table
+ WHERE id = %d", $meeting_id
+ ));
+
+ if (!$meeting) {
+ return new WP_REST_Response(['code' => 404, 'message' => 'Meeting not found.'], 404);
+ }
+
+ $participant_data = maybe_unserialize($meeting->participant_ids);
+ if (!is_array($participant_data)) {
+ $participant_data = [];
+ }
+
+ if (!array_key_exists($user_id, $participant_data)) {
+ return new WP_REST_Response(['code' => 403, 'message' => 'You are not a participant of this meeting.'], 403);
+ }
+
+ // If user is accepting, check for conflict in same slot
+ if ($new_status === 1) {
+ $event_id = $meeting->event_id;
+ $meeting_date = $meeting->meeting_date;
+ $slot = date('H:i', strtotime($meeting->meeting_start_time));
+
+ $conflicting_meeting = $wpdb->get_row($wpdb->prepare("
+ SELECT id FROM $table
+ WHERE id != %d
+ AND event_id = %d
+ AND meeting_date = %s
+ AND meeting_start_time = %s
+ AND meeting_status != -1
+ ", $meeting_id, $event_id, $meeting_date, $meeting->meeting_start_time));
+
+ if ($conflicting_meeting) {
+ $existing_participants = $wpdb->get_var($wpdb->prepare("
+ SELECT participant_ids FROM $table WHERE id = %d
+ ", $conflicting_meeting->id));
+
+ $existing_participant_data = maybe_unserialize($existing_participants);
+ if (is_array($existing_participant_data) && isset($existing_participant_data[$user_id]) && $existing_participant_data[$user_id] == 1) {
+ return new WP_REST_Response([
+ 'code' => 409,
+ 'message' => 'You already have a confirmed meeting scheduled at this time slot.',
+ ], 409);
+ }
+ }
+ }
+
+ // Update this user's status
+ $participant_data[$user_id] = $new_status;
+
+ // Determine overall meeting status
+ $meeting_status = (in_array(1, $participant_data, true)) ? 1 : 0;
+
+ // Update meeting record
+ $updated = $wpdb->update(
+ $table,
+ [
+ 'participant_ids' => maybe_serialize($participant_data),
+ 'meeting_status' => $meeting_status,
+ ],
+ ['id' => $meeting_id],
+ ['%s', '%d'],
+ ['%d']
+ );
+
+ if ($updated === false) {
+ return new WP_REST_Response(['code' => 500, 'message' => 'Failed to update meeting status.'], 500);
+ }
+
+ // Update availability slot for this user
+ $slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+ if (!is_array($slot_data)) {
+ $slot_data = [];
+ }
+
+ if (!isset($slot_data[$event_id])) {
+ $slot_data[$event_id] = [];
+ }
+ if (!isset($slot_data[$event_id][$meeting_date])) {
+ $slot_data[$event_id][$meeting_date] = [];
+ }
+
+ $slot_data[$event_id][$meeting_date][date('H:i', strtotime($meeting->meeting_start_time))] = ($new_status === 1) ? 2 : 1;
+
+ update_user_meta($user_id, '_meeting_availability_slot', $slot_data);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => $new_status ? 'Meeting accepted.' : 'Meeting declined.',
+ 'data' => [
+ 'meeting_id' => $meeting_id,
+ 'participant_id' => $user_id,
+ 'participant_status' => $new_status,
+ 'meeting_status' => $meeting_status,
+ ]
+ ], 200);
+ }
public function get_booked_meeting_slots(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
-
- global $wpdb;
-
- $event_id = intval($request->get_param('event_id'));
- $user_id = intval($request->get_param('user_id')) ?: get_current_user_id();
-
- if (!$event_id || !$user_id) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'error',
- 'message' => 'Missing event_id or unauthorized access.',
- 'data' => null
- ], 400);
- }
-
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
-
- // Get availability slot and available flag in single query
- $result = $wpdb->get_row(
- $wpdb->prepare("SELECT meeting_availability_slot, available_for_meeting FROM $table WHERE user_id = %d", $user_id),
- ARRAY_A
- );
-
- $saved_data = !empty($result['meeting_availability_slot']) ? maybe_unserialize($result['meeting_availability_slot']) : [];
- $available_flag = isset($result['available_for_meeting']) ? (int)$result['available_for_meeting'] : 0;
-
- $event_slots = $saved_data[$event_id] ?? [];
-
- if (is_array($event_slots)) {
- ksort($event_slots); // sort by date keys
- }
-
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Availability slots fetched successfully.',
- 'data' => [
- 'available_for_meeting' => $available_flag,
- 'slots' => $event_slots
- ]
- ], 200);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
+
+ $event_id = intval($request->get_param('event_id'));
+ $user_id = intval($request->get_param('user_id')) ?: get_current_user_id();
+
+ if (!$event_id || !$user_id) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'error',
+ 'message' => 'Missing event_id or unauthorized access.',
+ 'data' => null
+ ], 400);
+ }
+
+ $saved_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+ $available_flag = (int)get_user_meta($user_id, '_available_for_meeting', true);
+
+ $event_slots = $saved_data[$event_id] ?? [];
+
+ if (is_array($event_slots)) {
+ ksort($event_slots); // sort by date keys
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Availability slots fetched successfully.',
+ 'data' => [
+ 'available_for_meeting' => $available_flag,
+ 'slots' => $event_slots
+ ]
+ ], 200);
+ }
public function update_availability_slots_rest(WP_REST_Request $request) {
- global $wpdb;
- $table = $wpdb->prefix . 'wpem_matchmaking_users';
-
- $event_id = intval($request->get_param('event_id'));
- $submitted_slots = $request->get_param('availability_slots'); // Now: [ '2025-07-07' => [ '07:00' => 0 ] ]
- $available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
- $user_id = intval($request->get_param('user_id') ?: get_current_user_id());
-
- if (!$user_id || !$event_id || !is_array($submitted_slots)) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'ERROR',
- 'message' => 'Missing or invalid parameters.'
- ], 400);
- }
-
- $current_data = $wpdb->get_var($wpdb->prepare(
- "SELECT meeting_availability_slot FROM {$table} WHERE user_id = %d",
- $user_id
- ));
-
- $availability_data = [];
- if (!empty($current_data)) {
- $maybe_unserialized = maybe_unserialize($current_data);
- if (is_array($maybe_unserialized)) {
- $availability_data = $maybe_unserialized;
- }
- }
-
- // Ensure event structure exists
- if (!isset($availability_data[$event_id])) {
- $availability_data[$event_id] = [];
- }
-
- // Update the passed slots directly
- foreach ($submitted_slots as $date => $slots) {
- if (!isset($availability_data[$event_id][$date])) {
- $availability_data[$event_id][$date] = [];
- }
-
- foreach ($slots as $time => $value) {
- // Accept only 0, 1, or 2 as valid values
- if (in_array($value, [0, 1, 2], true)) {
- $availability_data[$event_id][$date][$time] = $value;
- }
- }
- }
-
- $updated = $wpdb->update(
- $table,
- [
- 'meeting_availability_slot' => maybe_serialize($availability_data),
- 'available_for_meeting' => $available_for_meeting,
- ],
- ['user_id' => $user_id],
- ['%s', '%d'],
- ['%d']
- );
-
- if ($updated !== false) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Availability updated successfully.'
- ], 200);
- } else {
- return new WP_REST_Response([
- 'code' => 500,
- 'status' => 'ERROR',
- 'message' => 'Failed to update availability.'
- ], 500);
- }
- }
- public function get_common_availability_slots($request) {
- global $wpdb;
-
- $event_id = intval($request->get_param('event_id'));
- $user_ids = $request->get_param('user_ids');
- $date = sanitize_text_field($request->get_param('date'));
-
- if (!is_array($user_ids) || empty($user_ids) || !$event_id || !$date) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'ERROR',
- 'message' => 'Invalid parameters.',
- 'data' => [],
- ], 400);
- }
-
- $placeholders = implode(',', array_fill(0, count($user_ids), '%d'));
- $query = "
- SELECT user_id, meeting_availability_slot
- FROM {$wpdb->prefix}wpem_matchmaking_users
- WHERE user_id IN ($placeholders)
- ";
- $prepared = $wpdb->prepare($query, $user_ids);
- $results = $wpdb->get_results($prepared);
-
- if (empty($results)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No common slots found.',
- 'data' => ['common_slots' => []],
- ]);
- }
-
- $all_user_slots = [];
-
- foreach ($results as $row) {
- $data = maybe_unserialize($row->meeting_availability_slot);
-
- if (
- empty($data) ||
- !isset($data[$event_id]) ||
- !isset($data[$event_id][$date]) ||
- !is_array($data[$event_id][$date])
- ) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No common slots found.',
- 'data' => ['common_slots' => []],
- ]);
- }
-
- // Filter only available slots (value === 1)
- $available_slots = array_keys(array_filter($data[$event_id][$date], function($v) {
- return $v === 1;
- }));
-
- if (empty($available_slots)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No common slots found.',
- 'data' => ['common_slots' => []],
- ]);
- }
-
- $all_user_slots[] = $available_slots;
- }
-
- // Only one user: return their available slots
- if (count($all_user_slots) === 1) {
- sort($all_user_slots[0]);
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Availability slots retrieved successfully.',
- 'data' => [
- 'event_id' => $event_id,
- 'date' => $date,
- 'common_slots' => array_values($all_user_slots[0]),
- ],
- ]);
- }
-
- // Multiple users: intersect available time slots
- $common_slots = array_shift($all_user_slots);
- foreach ($all_user_slots as $slots) {
- $common_slots = array_intersect($common_slots, $slots);
- }
-
- sort($common_slots);
-
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => empty($common_slots) ? 'No common slots found.' : 'Common availability slots retrieved successfully.',
- 'data' => [
- 'event_id' => $event_id,
- 'date' => $date,
- 'common_slots' => array_values($common_slots),
- ],
- ]);
- }
+ $event_id = intval($request->get_param('event_id'));
+ $submitted_slots = $request->get_param('availability_slots');
+ $available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
+ $user_id = intval($request->get_param('user_id') ?: get_current_user_id());
+
+ if (!$user_id || !$event_id || !is_array($submitted_slots)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'ERROR',
+ 'message' => 'Missing or invalid parameters.'
+ ], 400);
+ }
+
+ $current_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+ $availability_data = is_array($current_data) ? $current_data : [];
+
+ // Ensure event structure exists
+ if (!isset($availability_data[$event_id])) {
+ $availability_data[$event_id] = [];
+ }
+
+ // Update the passed slots directly
+ foreach ($submitted_slots as $date => $slots) {
+ if (!isset($availability_data[$event_id][$date])) {
+ $availability_data[$event_id][$date] = [];
+ }
+
+ foreach ($slots as $time => $value) {
+ if (in_array($value, [0, 1, 2], true)) {
+ $availability_data[$event_id][$date][$time] = $value;
+ }
+ }
+ }
+
+ // Update user meta
+ update_user_meta($user_id, '_meeting_availability_slot', $availability_data);
+ update_user_meta($user_id, '_available_for_meeting', $available_for_meeting);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Availability updated successfully.'
+ ], 200);
+ }
+ public function get_common_availability_slots($request) {
+ $event_id = intval($request->get_param('event_id'));
+ $user_ids = $request->get_param('user_ids');
+ $date = sanitize_text_field($request->get_param('date'));
+
+ if (!is_array($user_ids) || empty($user_ids) || !$event_id || !$date) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'ERROR',
+ 'message' => 'Invalid parameters.',
+ 'data' => [],
+ ], 400);
+ }
+
+ $all_user_slots = [];
+
+ foreach ($user_ids as $user_id) {
+ $data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+
+ if (
+ empty($data) ||
+ !isset($data[$event_id]) ||
+ !isset($data[$event_id][$date]) ||
+ !is_array($data[$event_id][$date])
+ ) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No common slots found.',
+ 'data' => ['common_slots' => []],
+ ]);
+ }
+
+ // Filter only available slots (value === 1)
+ $available_slots = array_keys(array_filter($data[$event_id][$date], function($v) {
+ return $v === 1;
+ }));
+
+ if (empty($available_slots)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No common slots found.',
+ 'data' => ['common_slots' => []],
+ ]);
+ }
+
+ $all_user_slots[] = $available_slots;
+ }
+
+ // Only one user: return their available slots
+ if (count($all_user_slots) === 1) {
+ sort($all_user_slots[0]);
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Availability slots retrieved successfully.',
+ 'data' => [
+ 'event_id' => $event_id,
+ 'date' => $date,
+ 'common_slots' => array_values($all_user_slots[0]),
+ ],
+ ]);
+ }
+
+ // Multiple users: intersect available time slots
+ $common_slots = array_shift($all_user_slots);
+ foreach ($all_user_slots as $slots) {
+ $common_slots = array_intersect($common_slots, $slots);
+ }
+
+ sort($common_slots);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => empty($common_slots) ? 'No common slots found.' : 'Common availability slots retrieved successfully.',
+ 'data' => [
+ 'event_id' => $event_id,
+ 'date' => $date,
+ 'common_slots' => array_values($common_slots),
+ ],
+ ]);
+ }
public function get_matchmaking_settings(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index d7e8e47..2c62089 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -48,7 +48,7 @@ public function register_routes() {
),
));
}
- public function handle_send_message($request) {
+ public function handle_send_message($request) {
global $wpdb;
if (!get_option('enable_matchmaking', false)) {
@@ -62,7 +62,9 @@ public function handle_send_message($request) {
$sender_id = intval($request->get_param('senderId'));
$receiver_id = intval($request->get_param('receiverId'));
$text_message = sanitize_textarea_field($request->get_param('message'));
- $sender_user = get_user_by('id', $sender_id);
+
+ // Get minimal user objects just for email addresses
+ $sender_user = get_user_by('id', $sender_id);
$receiver_user = get_user_by('id', $receiver_id);
if (!$sender_user || !$receiver_user) {
@@ -73,9 +75,24 @@ public function handle_send_message($request) {
], 404);
}
- $table_users = $wpdb->prefix . 'wpem_matchmaking_users';
- $sender_notify = $wpdb->get_var($wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $sender_id));
- $receiver_notify = $wpdb->get_var($wpdb->prepare("SELECT message_notification FROM $table_users WHERE user_id = %d", $receiver_id));
+ // Get other user data from meta
+ $sender_display_name = get_user_meta($sender_id, 'display_name', true);
+ if (empty($sender_display_name)) {
+ $first_name = get_user_meta($sender_id, 'first_name', true);
+ $last_name = get_user_meta($sender_id, 'last_name', true);
+ $sender_display_name = trim("$first_name $last_name");
+ }
+
+ $receiver_display_name = get_user_meta($receiver_id, 'display_name', true);
+ if (empty($receiver_display_name)) {
+ $first_name = get_user_meta($receiver_id, 'first_name', true);
+ $last_name = get_user_meta($receiver_id, 'last_name', true);
+ $receiver_display_name = trim("$first_name $last_name");
+ }
+
+ // Get notification preferences (assuming stored in meta)
+ $sender_notify = get_user_meta($sender_id, '_message_notification', true);
+ $receiver_notify = get_user_meta($receiver_id, '_message_notification', true);
if ($sender_notify != 1 || $receiver_notify != 1) {
return new WP_REST_Response([
@@ -130,9 +147,10 @@ public function handle_send_message($request) {
$insert_id = $wpdb->insert_id;
+ // Use email from user object
wp_mail(
$receiver_user->user_email,
- 'New Message from ' . $sender_user->display_name,
+ 'New Message from ' . $sender_display_name,
$final_message,
['Content-Type: text/plain; charset=UTF-8']
);
@@ -233,7 +251,6 @@ public function handle_get_conversation_list($request) {
$postmeta = $wpdb->postmeta;
$messages_tbl = $wpdb->prefix . 'wpem_matchmaking_users_messages';
- $profile_tbl = $wpdb->prefix . 'wpem_matchmaking_users';
// Step 1: Get users registered in the same events (excluding self)
$event_placeholders = implode(',', array_fill(0, count($event_ids), '%d'));
@@ -297,7 +314,7 @@ public function handle_get_conversation_list($request) {
$offset = ($paged - 1) * $per_page;
$paginated_ids = array_slice($valid_user_ids, $offset, $per_page);
- // Step 5: Build user info with last message
+ // Step 5: Build user info with last message (using user meta)
$results = [];
foreach ($paginated_ids as $uid) {
// Get last message exchanged
@@ -309,15 +326,24 @@ public function handle_get_conversation_list($request) {
LIMIT 1
", $user_id, $uid, $uid, $user_id));
+ // Get display name from meta with fallback
+ $display_name = get_user_meta($uid, 'display_name', true);
+ if (empty($display_name)) {
+ $first_name = get_user_meta($uid, 'first_name', true);
+ $last_name = get_user_meta($uid, 'last_name', true);
+ $display_name = trim("$first_name $last_name");
+ }
+
$results[] = [
'user_id' => (int) $uid,
'first_name' => get_user_meta($uid, 'first_name', true),
'last_name' => get_user_meta($uid, 'last_name', true),
- 'profile_photo' => $wpdb->get_var($wpdb->prepare("SELECT profile_photo FROM $profile_tbl WHERE user_id = %d", $uid)),
- 'profession' => $wpdb->get_var($wpdb->prepare("SELECT profession FROM $profile_tbl WHERE user_id = %d", $uid)),
- 'company_name' => $wpdb->get_var($wpdb->prepare("SELECT company_name FROM $profile_tbl WHERE user_id = %d", $uid)),
+ 'display_name' => $display_name,
+ 'profile_photo' => get_user_meta($uid, '_profile_photo', true),
+ 'profession' => get_user_meta($uid, '_profession', true),
+ 'company_name' => get_user_meta($uid, '_company_name', true),
'last_message' => $last_message_row ? $last_message_row->message : null,
- 'message_time' => $last_message_row ? date('Y-m-d H:i:s', strtotime($last_message_row->created_at)) : null,
+ 'message_time' => $last_message_row ? date('Y-m-d H:i:s', strtotime($last_message_row->created_at)) : null,
];
}
From 0e92551c982d188ec148d1ffbe157e3a5e2c5dff Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 4 Aug 2025 16:55:53 +0530
Subject: [PATCH 089/171] #181 Change in api
---
includes/wpem-rest-matchmaking-user-registred-events.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-registred-events.php b/includes/wpem-rest-matchmaking-user-registred-events.php
index c615f58..e32a39e 100644
--- a/includes/wpem-rest-matchmaking-user-registred-events.php
+++ b/includes/wpem-rest-matchmaking-user-registred-events.php
@@ -36,12 +36,13 @@ public function get_user_registered_events($request) {
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids',
- 'meta_query' => array(
+ 'author' => $target_user_id,
+ /*'meta_query' => array(
array(
'key' => '_attendee_user_id',
'value' => $target_user_id,
)
- ),
+ ),*/
);
$query = new WP_Query($args);
From db444190a516d005e6f2128eccbaf1864947d1a6 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 4 Aug 2025 17:40:33 +0530
Subject: [PATCH 090/171] #181 Change in get registered event list
---
includes/wpem-rest-matchmaking-profile.php | 17 ++++++-----------
...m-rest-matchmaking-user-registred-events.php | 10 ++--------
2 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 5e586cc..fea3de1 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -188,15 +188,15 @@ public function update_attendee_profile($request) {
// List of all meta fields we can update
$meta_fields = [
- '_profession', '_experience', '_company_name', '_country',
- '_city', '_about', '_skills', '_interests', '_organization_name',
- '_organization_logo', '_organization_city', '_organization_country',
- '_organization_description', '_message_notification', '_matchmaking_profile'
+ 'profession', 'experience', 'company_name', 'country',
+ 'city', 'about', 'skills', 'interests', 'organization_name',
+ 'organization_logo', 'organization_city', 'organization_country',
+ 'organization_description', 'message_notification', 'matchmaking_profile'
];
// Handle normal meta fields
foreach ($meta_fields as $field) {
- $param_name = str_replace('_', '', $field); // Remove underscore for request param
+
if ($request->get_param($param_name) !== null) {
$value = $request->get_param($param_name);
@@ -205,12 +205,7 @@ public function update_attendee_profile($request) {
$value = maybe_serialize((array)$value);
}
- // Special handling for numeric fields
- if ($field === '_experience') {
- $value = (float)$value;
- }
-
- update_user_meta($user_id, $field, $value);
+ update_user_meta($user_id, '_'.$field, $value);
}
}
diff --git a/includes/wpem-rest-matchmaking-user-registred-events.php b/includes/wpem-rest-matchmaking-user-registred-events.php
index e32a39e..c4e4dae 100644
--- a/includes/wpem-rest-matchmaking-user-registred-events.php
+++ b/includes/wpem-rest-matchmaking-user-registred-events.php
@@ -36,20 +36,14 @@ public function get_user_registered_events($request) {
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids',
- 'author' => $target_user_id,
- /*'meta_query' => array(
- array(
- 'key' => '_attendee_user_id',
- 'value' => $target_user_id,
- )
- ),*/
+ 'post_author' => $target_user_id,
);
$query = new WP_Query($args);
$event_ids = array();
foreach ($query->posts as $registration_id) {
- $event_id = get_post_meta($registration_id, '_event_id', true);
+ $event_id = wp_get_post_parent_id($registration_id);
if (!empty($event_id) && !in_array($event_id, $event_ids)) {
$event_ids[] = (int) $event_id;
}
From 53c971c591eba219ed3e7a65d2e7a6d7397909b5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 4 Aug 2025 18:34:27 +0530
Subject: [PATCH 091/171] #183 Attendee-profile Update not working
---
includes/wpem-rest-matchmaking-profile.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index fea3de1..6224c1a 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -197,11 +197,11 @@ public function update_attendee_profile($request) {
// Handle normal meta fields
foreach ($meta_fields as $field) {
- if ($request->get_param($param_name) !== null) {
- $value = $request->get_param($param_name);
+ if ($request->get_param($field) !== null) {
+ $value = $request->get_param($field);
// Special handling for array fields
- if (in_array($field, ['_skills', '_interests'])) {
+ if (in_array($field, ['skills', 'interests'])) {
$value = maybe_serialize((array)$value);
}
From d26e8019610d12eed6795962fbf6798b3c443604 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 4 Aug 2025 19:11:50 +0530
Subject: [PATCH 092/171] #184 Filter-users API not working
---
includes/wpem-rest-matchmaking-filter-users.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 41da1f6..415e6e9 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -206,11 +206,11 @@ public function handle_filter_users($request) {
'post_type' => 'event_registration',
'posts_per_page' => -1,
'fields' => 'ids',
- 'meta_query' => [['key' => '_event_id', 'value' => $event_id]],
+ 'post_parent' => $event_id,
]);
foreach ($attendee_query->posts as $post_id) {
- $uid = get_post_meta($post_id, '_attendee_user_id', true);
+ $uid = wp_get_post_parent_id($post_id);
if ($uid && $uid != $current_user_id && !in_array($uid, $user_ids)) {
$user_ids[] = (int)$uid;
}
From f322a4a385541875aef98da9d5d8c5a70d2409aa Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 09:55:26 +0530
Subject: [PATCH 093/171] #184 Filter-users API not working
---
.../wpem-rest-matchmaking-filter-users.php | 276 ++++++------------
1 file changed, 92 insertions(+), 184 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 415e6e9..3c54975 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -156,7 +156,10 @@ public function handle_your_matches($request) {
return $response;
}
-public function handle_filter_users($request) {
+ public function handle_filter_users($request) {
+
+ global $wpdb;
+
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
'code' => 403,
@@ -166,33 +169,28 @@ public function handle_filter_users($request) {
], 403);
}
- $event_id = $request->get_param('event_id');
- $current_user_id = $request->get_param('user_id');
- $user_ids = [];
-
- // Handle event-specific filtering
- if (!empty($event_id)) {
- if (!$current_user_id) {
- return new WP_REST_Response([
- 'code' => 401,
- 'status' => 'Unauthorized',
- 'message' => 'User not logged in.',
- 'data' => []
- ], 401);
- }
+ $event_id = intval($request->get_param('event_id'));
+ $user_id = intval($request->get_param('user_id'));
- // Check if current user is registered for the event
+ // Step 1: Get all registered user IDs for this event (from post_parent)
+ $registered_user_ids = [];
+ if ($event_id && $user_id) {
$registration_query = new WP_Query([
'post_type' => 'event_registration',
'posts_per_page' => -1,
'fields' => 'ids',
- 'meta_query' => [
- ['key' => '_attendee_user_id', 'value' => $current_user_id],
- ['key' => '_event_id', 'value' => $event_id],
- ],
+ 'post_author' => $user_id,
]);
- if (!$registration_query->have_posts()) {
+ $has_registration = false;
+ foreach ($registration_query->posts as $registration_id) {
+ if (wp_get_post_parent_id($registration_id) == $event_id) {
+ $has_registration = true;
+ break;
+ }
+ }
+
+ if (!$has_registration) {
return new WP_REST_Response([
'code' => 403,
'status' => 'Forbidden',
@@ -201,204 +199,114 @@ public function handle_filter_users($request) {
], 403);
}
- // Get all attendees for this event
+ // Now get all users for this event
$attendee_query = new WP_Query([
'post_type' => 'event_registration',
'posts_per_page' => -1,
- 'fields' => 'ids',
- 'post_parent' => $event_id,
+ 'fields' => 'ids'
]);
-
- foreach ($attendee_query->posts as $post_id) {
- $uid = wp_get_post_parent_id($post_id);
- if ($uid && $uid != $current_user_id && !in_array($uid, $user_ids)) {
- $user_ids[] = (int)$uid;
+
+ foreach ($attendee_query->posts as $registration_id) {
+
+ if (wp_get_post_parent_id($registration_id) == $event_id) {
+ $uid = get_post_field('post_author', $registration_id);
+ if ($uid && !in_array($uid, $registered_user_ids)) {
+ $registered_user_ids[] = intval($uid);
+ }
}
}
+
+ }
- if (empty($user_ids)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No attendees found for this event.',
- 'data' => []
- ], 200);
- }
+ if (empty($registered_user_ids)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No attendees found for this event.',
+ 'data' => []
+ ], 200);
}
- // Get all users with matchmaking profile first
- $all_users = get_users([
- 'meta_key' => '_matchmaking_profile',
- 'meta_value' => '1',
- 'meta_compare' => '=',
- ]);
+ // Step 2: Build the full user data from usermeta
+ $users_data = [];
+ foreach ($registered_user_ids as $uid) {
+ $users_data[] = [
+ 'user_id' => $uid,
+ 'display_name' => get_the_author_meta('display_name', $uid),
+ 'first_name' => get_user_meta($uid, 'first_name', true),
+ 'last_name' => get_user_meta($uid, 'last_name', true),
+ 'email' => get_userdata($uid)->user_email,
+ 'matchmaking_profile' => get_user_meta($uid, '_matchmaking_profile', true),
+ 'profile_photo' => get_user_meta($uid, '_profile_photo', true),
+ 'profession' => get_user_meta($uid, '_profession', true),
+ 'experience' => get_user_meta($uid, '_experience', true),
+ 'company_name' => get_user_meta($uid, '_company_name', true),
+ 'country' => get_user_meta($uid, '_country', true),
+ 'city' => get_user_meta($uid, '_city', true),
+ 'about' => get_user_meta($uid, '_about', true),
+ 'skills' => get_user_meta($uid, '_skills', true),
+ 'interests' => get_user_meta($uid, '_interests', true),
+ 'message_notification' => get_user_meta($uid, '_message_notification', true),
+ 'organization_name' => get_user_meta($uid, '_organization_name', true),
+ 'organization_logo' => get_user_meta($uid, '_organization_logo', true),
+ 'organization_country' => get_user_meta($uid, '_organization_country', true),
+ 'organization_city' => get_user_meta($uid, '_organization_city', true),
+ 'organization_description'=> get_user_meta($uid, '_organization_description', true),
+ ];
+ }
- // Filter users based on criteria
- $filtered_users = array_filter($all_users, function($user) use ($request, $user_ids) {
- $user_meta = get_user_meta($user->ID);
-
- // If event_id provided, only include users in the attendee list
- if (!empty($user_ids) && !in_array($user->ID, $user_ids)) {
+ // Step 3: Apply filters
+ $profession = sanitize_text_field($request->get_param('profession'));
+ $country = $request->get_param('country');
+ $skills = $request->get_param('skills');
+ $interests = $request->get_param('interests');
+ $search = sanitize_text_field($request->get_param('search'));
+
+ $filtered_users = array_filter($users_data, function($user) use ($profession, $country, $skills, $interests, $search) {
+ if ($profession && strtolower($user['profession']) !== strtolower($profession)) {
return false;
}
-
- // Profession filter
- if ($profession = sanitize_text_field($request->get_param('profession'))) {
- if (empty($user_meta['_profession'][0])) return false;
- if (strcasecmp($user_meta['_profession'][0], $profession) !== 0)
- return false;
+ if (!empty($country) && is_array($country) && !in_array($user['country'], $country)) {
+ return false;
}
-
- // Experience filter
- $experience = $request->get_param('experience');
- if (is_array($experience)) {
- $user_exp = isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0;
- if (isset($experience['min']) && is_numeric($experience['min']) && $user_exp < (float)$experience['min']) {
+ if (!empty($skills) && is_array($skills)) {
+ $user_skills = maybe_unserialize($user['skills']);
+ if (!array_intersect($skills, $user_skills)) {
return false;
}
- if (isset($experience['max']) && is_numeric($experience['max']) && $user_exp > (float)$experience['max']) {
- return false;
- }
- } elseif (is_numeric($experience)) {
- $user_exp = isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0;
- if ($user_exp != (float)$experience) {
- return false;
- }
- }
-
- // Company name filter
- if ($company = sanitize_text_field($request->get_param('company_name'))) {
- if (empty($user_meta['_company_name'][0])) return false;
- if (strcasecmp($user_meta['_company_name'][0], $company) !== 0) return false;
}
-
- // Country filter
- $countries = $request->get_param('country');
- if (is_array($countries) && !empty($countries)) {
- if (empty($user_meta['_country'][0])) return false;
- if (!in_array(strtolower($user_meta['_country'][0]), array_map('strtolower', $countries))) {
+ if (!empty($interests) && is_array($interests)) {
+ $user_interests = maybe_unserialize($user['interests']);
+ if (!array_intersect($interests, $user_interests)) {
return false;
}
- } elseif (!empty($countries)) {
- if (empty($user_meta['_country'][0])) return false;
- if (strcasecmp($user_meta['_country'][0], $countries) !== 0) return false;
}
-
- // City filter
- if ($city = sanitize_text_field($request->get_param('city'))) {
- if (empty($user_meta['_city'][0])) return false;
- if (strcasecmp($user_meta['_city'][0], $city) !== 0) return false;
- }
-
- // Skills filter
- $skills = $request->get_param('skills');
- if (is_array($skills) && !empty($skills)) {
- if (empty($user_meta['_skills'][0])) return false;
- $user_skills = maybe_unserialize($user_meta['_skills'][0]);
- if (!is_array($user_skills)) return false;
-
- $found = false;
- foreach ($skills as $skill) {
- if (in_array($skill, $user_skills)) {
- $found = true;
- break;
- }
- }
- if (!$found) return false;
- }
-
- // Interests filter
- $interests = $request->get_param('interests');
- if (is_array($interests) && !empty($interests)) {
- if (empty($user_meta['_interests'][0])) return false;
- $user_interests = maybe_unserialize($user_meta['_interests'][0]);
- if (!is_array($user_interests)) return false;
-
- $found = false;
- foreach ($interests as $interest) {
- if (in_array($interest, $user_interests)) {
- $found = true;
- break;
- }
- }
- if (!$found) return false;
- }
-
- // Search filter
- $search = sanitize_text_field($request->get_param('search'));
- if (!empty($search)) {
- $found = false;
-
- // Search in profile fields
- $profile_fields = ['_about', '_city', '_country', '_profession', '_company_name'];
- foreach ($profile_fields as $field) {
- if (!empty($user_meta[$field][0]) && stripos($user_meta[$field][0], $search) !== false) {
- $found = true;
- break;
- }
- }
-
- // Search in user name fields
- if (!$found) {
- $first_name = get_user_meta($user->ID, 'first_name', true);
- $last_name = get_user_meta($user->ID, 'last_name', true);
- if (stripos($first_name, $search) !== false || stripos($last_name, $search) !== false) {
- $found = true;
- }
- }
-
- if (!$found) return false;
- }
-
- // Manual approval filter
- if (get_option('participant_activation') === 'manual') {
- if (empty($user_meta['_approve_profile_status'][0]) || $user_meta['_approve_profile_status'][0] != '1') {
+ if ($search) {
+ $haystack = strtolower(implode(' ', $user));
+ if (strpos($haystack, strtolower($search)) === false) {
return false;
}
}
-
return true;
});
- // Pagination
+ // Step 4: Pagination
$per_page = max(1, (int) $request->get_param('per_page'));
- $page = max(1, (int) $request->get_param('page'));
- $total = count($filtered_users);
- $offset = ($page - 1) * $per_page;
- $paginated_users = array_slice($filtered_users, $offset, $per_page);
-
- // Format results
- $formatted_results = [];
- foreach ($paginated_users as $user) {
- $user_meta = get_user_meta($user->ID);
- $formatted_results[] = [
- 'user_id' => $user->ID,
- 'first_name' => $user_meta['first_name'][0] ?? '',
- 'last_name' => $user_meta['last_name'][0] ?? '',
- 'profession' => $user_meta['_profession'][0] ?? '',
- 'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
- 'company_name' => $user_meta['_company_name'][0] ?? '',
- 'country' => $user_meta['_country'][0] ?? '',
- 'city' => $user_meta['_city'][0] ?? '',
- 'about' => $user_meta['_about'][0] ?? '',
- 'skills' => isset($user_meta['_skills'][0]) ? maybe_unserialize($user_meta['_skills'][0]) : [],
- 'interests' => isset($user_meta['_interests'][0]) ? maybe_unserialize($user_meta['_interests'][0]) : [],
- 'profile_photo' => $user_meta['_profile_photo'][0] ?? '',
- 'organization_name' => $user_meta['_organization_name'][0] ?? '',
- 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : [],
- ];
- }
+ $page = max(1, (int) $request->get_param('page'));
+ $total = count($filtered_users);
+ $offset = ($page - 1) * $per_page;
+ $paged_users = array_slice($filtered_users, $offset, $per_page);
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
'message' => 'Users retrieved successfully.',
- 'data' => [
+ 'data' => [
'total_post_count' => $total,
'current_page' => $page,
'last_page' => ceil($total / $per_page),
'total_pages' => ceil($total / $per_page),
- 'users' => $formatted_results,
+ 'users' => array_values($paged_users),
],
], 200);
}
From 67ec7ffdc63803e4b234d79b5fa715e27188e532 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 12:08:41 +0530
Subject: [PATCH 094/171] #182 Changes in Match making APIs due to changes in
database table changes
---
.../wpem-rest-matchmaking-user-messages.php | 104 +++++++++++++++++-
1 file changed, 102 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 2c62089..44b9391 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -233,7 +233,7 @@ public function handle_get_messages($request) {
]
], 200);
}
- public function handle_get_conversation_list($request) {
+ /*public function handle_get_conversation_list($request) {
global $wpdb;
$user_id = intval($request->get_param('user_id'));
@@ -361,7 +361,107 @@ public function handle_get_conversation_list($request) {
'users' => $results
]
], 200);
- }
+ }*/
+ public function handle_get_conversation_list($request) {
+ global $wpdb;
+
+ $user_id = intval($request->get_param('user_id'));
+ $paged = max(1, intval($request->get_param('paged')));
+ $per_page = max(1, intval($request->get_param('per_page')));
+
+ if (empty($user_id)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'user_id is required.',
+ ], 400);
+ }
+
+ $messages_tbl = $wpdb->prefix . 'wpem_matchmaking_users_messages';
+
+ /**
+ * Step 1: Get all unique conversation partners
+ */
+ $conversation_user_ids = $wpdb->get_col($wpdb->prepare("
+ SELECT DISTINCT other_user FROM (
+ SELECT receiver_id AS other_user FROM $messages_tbl WHERE sender_id = %d
+ UNION
+ SELECT sender_id AS other_user FROM $messages_tbl WHERE receiver_id = %d
+ ) AS temp
+ WHERE other_user != %d
+ ", $user_id, $user_id, $user_id));
+
+ if (empty($conversation_user_ids)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No conversation history found.',
+ 'data' => [
+ 'total_users' => 0,
+ 'current_page' => $paged,
+ 'last_page' => 0,
+ 'users' => []
+ ]
+ ], 200);
+ }
+
+ /**
+ * Step 2: Pagination
+ */
+ $total_count = count($conversation_user_ids);
+ $last_page = ceil($total_count / $per_page);
+ $offset = ($paged - 1) * $per_page;
+ $paginated_ids = array_slice($conversation_user_ids, $offset, $per_page);
+
+ /**
+ * Step 3: Build conversation list with last message
+ */
+ $results = [];
+ foreach ($paginated_ids as $partner_id) {
+ // Get last message between the two users
+ $last_message_row = $wpdb->get_row($wpdb->prepare("
+ SELECT message, created_at
+ FROM $messages_tbl
+ WHERE (sender_id = %d AND receiver_id = %d)
+ OR (sender_id = %d AND receiver_id = %d)
+ ORDER BY created_at DESC
+ LIMIT 1
+ ", $user_id, $partner_id, $partner_id, $user_id));
+
+ // Build display name
+ $display_name = get_user_meta($partner_id, 'display_name', true);
+ if (empty($display_name)) {
+ $first_name = get_user_meta($partner_id, 'first_name', true);
+ $last_name = get_user_meta($partner_id, 'last_name', true);
+ $display_name = trim("$first_name $last_name");
+ }
+
+ $results[] = [
+ 'user_id' => (int) $partner_id,
+ 'first_name' => get_user_meta($partner_id, 'first_name', true),
+ 'last_name' => get_user_meta($partner_id, 'last_name', true),
+ 'display_name' => $display_name,
+ 'profile_photo' => get_user_meta($partner_id, '_profile_photo', true),
+ 'profession' => get_user_meta($partner_id, '_profession', true),
+ 'company_name' => get_user_meta($partner_id, '_company_name', true),
+ 'last_message' => $last_message_row ? $last_message_row->message : null,
+ 'message_time' => $last_message_row ? date('Y-m-d H:i:s', strtotime($last_message_row->created_at)) : null,
+ ];
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Conversation list retrieved successfully.',
+ 'data' => [
+ 'total_users' => $total_count,
+ 'current_page' => $paged,
+ 'per_page' => $per_page,
+ 'last_page' => $last_page,
+ 'users' => $results
+ ]
+ ], 200);
+ }
}
new WPEM_REST_Send_Message_Controller();
From 275a0586ff953dcc0fc8f343edcc48cfff82aeb6 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 13:12:34 +0530
Subject: [PATCH 095/171] #182 Changes in Match making APIs due to changes in
database table changes
---
includes/wpem-rest-authentication.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index eb0515a..49bcb2e 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -733,8 +733,7 @@ public function perform_user_authentication($request) {
'country' => get_user_meta($user_id, '_country', true) ?: '',
'city' => get_user_meta($user_id, '_city', true) ?: '',
'about' => get_user_meta($user_id, '_about', true) ?: '',
- 'skills' => maybe_unserialize(get_user_meta($user_id, '
- _skills', true)) ?: [],
+ 'skills' => maybe_unserialize(get_user_meta($user_id, '_skills', true)) ?: [],
'interests' => maybe_unserialize(get_user_meta($user_id, '_interests', true)) ?: [],
'organizationName' => get_user_meta($user_id, '_organization_name', true) ?: '',
'organizationLogo' => get_user_meta($user_id, '_organization_logo', true) ?: '',
From 8b254ae89b440b395caeee78559ba6883cf5c63d Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 13:26:07 +0530
Subject: [PATCH 096/171] #182 Changes in Match making APIs due to changes in
database table changes
---
.../wpem-rest-matchmaking-create-meetings.php | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index e15d89b..4ac0925 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -57,10 +57,6 @@ public function register_routes() {
'callback' => [$this, 'get_booked_meeting_slots'],
'permission_callback' => [$auth_controller, 'check_authentication'],
'args' => [
- 'event_id' => [
- 'required' => true,
- 'type' => 'integer'
- ],
'user_id' => [
'required' => false,
'type' => 'integer'
@@ -624,21 +620,10 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
], 403);
}
- $event_id = intval($request->get_param('event_id'));
$user_id = intval($request->get_param('user_id')) ?: get_current_user_id();
- if (!$event_id || !$user_id) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'error',
- 'message' => 'Missing event_id or unauthorized access.',
- 'data' => null
- ], 400);
- }
-
$saved_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
$available_flag = (int)get_user_meta($user_id, '_available_for_meeting', true);
-
$event_slots = $saved_data[$event_id] ?? [];
if (is_array($event_slots)) {
@@ -651,7 +636,7 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
'message' => 'Availability slots fetched successfully.',
'data' => [
'available_for_meeting' => $available_flag,
- 'slots' => $event_slots
+ 'slots' => $saved_data
]
], 200);
}
From 91d99e1a856a1017bf4017617fe553cea4047747 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 14:57:32 +0530
Subject: [PATCH 097/171] #182 Changes in Match making APIs due to changes in
database table changes
---
includes/wpem-rest-matchmaking-create-meetings.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 4ac0925..72cf457 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -624,10 +624,9 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
$saved_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
$available_flag = (int)get_user_meta($user_id, '_available_for_meeting', true);
- $event_slots = $saved_data[$event_id] ?? [];
- if (is_array($event_slots)) {
- ksort($event_slots); // sort by date keys
+ if (is_array($saved_data)) {
+ ksort($saved_data); // sort by date keys
}
return new WP_REST_Response([
From 6e892cbde8075bf19de0a3117e350970369bed63 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 14:59:18 +0530
Subject: [PATCH 098/171] #182 Issue from org app in get texonomy api
---
includes/wpem-rest-matchmaking-get-texonomy.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-get-texonomy.php b/includes/wpem-rest-matchmaking-get-texonomy.php
index 056e407..0bf22f2 100644
--- a/includes/wpem-rest-matchmaking-get-texonomy.php
+++ b/includes/wpem-rest-matchmaking-get-texonomy.php
@@ -77,7 +77,7 @@ public function get_taxonomy_terms($request) {
private function format_term_data($term) {
return array(
'id' => $term->term_id,
- 'name' => $term->name,
+ 'name' => html_entity_decode($term->name, ENT_QUOTES, 'UTF-8'),
'slug' => $term->slug,
);
}
From cb403267c6e7f7c17773a18d480d3ee6140928a2 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 15:10:30 +0530
Subject: [PATCH 099/171] #182 Changes in Match making APIs due to changes in
database table changes
---
.../wpem-rest-matchmaking-create-meetings.php | 73 +++++++------------
1 file changed, 26 insertions(+), 47 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 72cf457..3f82a30 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -52,7 +52,7 @@ public function register_routes() {
'status' => ['required' => true, 'type' => 'integer', 'enum' => [0, 1]],
],
]);
- register_rest_route($this->namespace, '/get-availability-slots', [
+ register_rest_route($this->namespace, '/get-availability-slots', [
'methods' => WP_REST_Server::READABLE,
'callback' => [$this, 'get_booked_meeting_slots'],
'permission_callback' => [$auth_controller, 'check_authentication'],
@@ -68,10 +68,6 @@ public function register_routes() {
'callback' => [$this, 'update_availability_slots_rest'],
'permission_callback' => [$auth_controller, 'check_authentication'],
'args' => [
- 'event_id' => [
- 'required' => true,
- 'type' => 'integer'
- ],
'availability_slots' => [
'required' => true,
'type' => 'object'
@@ -640,51 +636,34 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
], 200);
}
public function update_availability_slots_rest(WP_REST_Request $request) {
- $event_id = intval($request->get_param('event_id'));
- $submitted_slots = $request->get_param('availability_slots');
- $available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
- $user_id = intval($request->get_param('user_id') ?: get_current_user_id());
-
- if (!$user_id || !$event_id || !is_array($submitted_slots)) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'ERROR',
- 'message' => 'Missing or invalid parameters.'
- ], 400);
- }
-
- $current_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
- $availability_data = is_array($current_data) ? $current_data : [];
-
- // Ensure event structure exists
- if (!isset($availability_data[$event_id])) {
- $availability_data[$event_id] = [];
- }
-
- // Update the passed slots directly
- foreach ($submitted_slots as $date => $slots) {
- if (!isset($availability_data[$event_id][$date])) {
- $availability_data[$event_id][$date] = [];
- }
+ $submitted_slots = $request->get_param('availability_slots'); // This is the "slots" array from GET
+
+ $available_for_meeting = $request->get_param('available_for_meeting') ? 1 : 0;
+ $user_id = intval($request->get_param('user_id') ?: get_current_user_id());
- foreach ($slots as $time => $value) {
- if (in_array($value, [0, 1, 2], true)) {
- $availability_data[$event_id][$date][$time] = $value;
- }
- }
- }
+ if (!$user_id || !is_array($submitted_slots)) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'ERROR',
+ 'message' => 'Missing or invalid parameters.'
+ ], 400);
+ }
- // Update user meta
- update_user_meta($user_id, '_meeting_availability_slot', $availability_data);
- update_user_meta($user_id, '_available_for_meeting', $available_for_meeting);
+ // Save directly in the same structure
+ update_user_meta($user_id, '_meeting_availability_slot', $submitted_slots);
+ update_user_meta($user_id, '_available_for_meeting', $available_for_meeting);
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Availability updated successfully.'
- ], 200);
- }
- public function get_common_availability_slots($request) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Availability updated successfully.',
+ 'data' => [
+ 'available_for_meeting' => $available_for_meeting,
+ 'slots' => $submitted_slots
+ ]
+ ], 200);
+ }
+ public function get_common_availability_slots($request) {
$event_id = intval($request->get_param('event_id'));
$user_ids = $request->get_param('user_ids');
$date = sanitize_text_field($request->get_param('date'));
From 0c6893bc5072a119eac92439ff07976587289071 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 5 Aug 2025 15:38:46 +0530
Subject: [PATCH 100/171] #182 Change in get common meeting availability slot
api
---
.../wpem-rest-matchmaking-create-meetings.php | 169 ++++++++++--------
1 file changed, 94 insertions(+), 75 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 3f82a30..fef1663 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -664,89 +664,108 @@ public function update_availability_slots_rest(WP_REST_Request $request) {
], 200);
}
public function get_common_availability_slots($request) {
- $event_id = intval($request->get_param('event_id'));
- $user_ids = $request->get_param('user_ids');
- $date = sanitize_text_field($request->get_param('date'));
+ global $wpdb;
- if (!is_array($user_ids) || empty($user_ids) || !$event_id || !$date) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'ERROR',
- 'message' => 'Invalid parameters.',
- 'data' => [],
- ], 400);
- }
+ $event_id = intval($request->get_param('event_id'));
+ $user_ids = $request->get_param('user_ids');
+ $date = sanitize_text_field($request->get_param('date'));
- $all_user_slots = [];
-
- foreach ($user_ids as $user_id) {
- $data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
-
- if (
- empty($data) ||
- !isset($data[$event_id]) ||
- !isset($data[$event_id][$date]) ||
- !is_array($data[$event_id][$date])
- ) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No common slots found.',
- 'data' => ['common_slots' => []],
- ]);
- }
+ if (!is_array($user_ids) || empty($user_ids) || !$event_id || !$date) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'ERROR',
+ 'message' => 'Invalid parameters.',
+ 'data' => [],
+ ], 400);
+ }
- // Filter only available slots (value === 1)
- $available_slots = array_keys(array_filter($data[$event_id][$date], function($v) {
- return $v === 1;
- }));
-
- if (empty($available_slots)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No common slots found.',
- 'data' => ['common_slots' => []],
- ]);
- }
+ $all_user_slots = [];
- $all_user_slots[] = $available_slots;
- }
+ // Step 1: Get available slots for each user (value === 1)
+ foreach ($user_ids as $user_id) {
+ $raw_data = get_wpem_default_meeting_slots_for_user($user_id, $date);
+
+ $available_slots = array_keys(array_filter(
+ $raw_data,
+ fn($v) => $v == 1
+ ));
+
+ if (empty($available_slots)) {
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No common slots found.',
+ 'data' => ['common_slots' => []],
+ ]);
+ }
- // Only one user: return their available slots
- if (count($all_user_slots) === 1) {
- sort($all_user_slots[0]);
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Availability slots retrieved successfully.',
- 'data' => [
- 'event_id' => $event_id,
- 'date' => $date,
- 'common_slots' => array_values($all_user_slots[0]),
- ],
- ]);
- }
+ $all_user_slots[] = $available_slots;
+ }
- // Multiple users: intersect available time slots
- $common_slots = array_shift($all_user_slots);
- foreach ($all_user_slots as $slots) {
- $common_slots = array_intersect($common_slots, $slots);
- }
+ // Step 2: Find intersection of slots between all users
+ $common_slots = array_shift($all_user_slots);
+ foreach ($all_user_slots as $slots) {
+ $common_slots = array_intersect($common_slots, $slots);
+ }
- sort($common_slots);
+ sort($common_slots);
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => empty($common_slots) ? 'No common slots found.' : 'Common availability slots retrieved successfully.',
- 'data' => [
- 'event_id' => $event_id,
- 'date' => $date,
- 'common_slots' => array_values($common_slots),
- ],
- ]);
- }
+ // Step 3: Find booked slots for given date
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $rows = $wpdb->get_results($wpdb->prepare(
+ "SELECT meeting_start_time, participant_ids, user_id
+ FROM {$table}
+ WHERE meeting_date = %s",
+ $date
+ ), ARRAY_A);
+
+ $booked_slots = [];
+ foreach ($rows as $row) {
+ $meeting_time = date('H:i', strtotime($row['meeting_start_time']));
+ $creator_id = intval($row['user_id']);
+ $participant_ids = maybe_unserialize($row['participant_ids']);
+
+ if (!is_array($participant_ids)) {
+ $participant_ids = [];
+ }
+
+ foreach ($user_ids as $u_id) {
+ $u_id = intval($u_id);
+
+ // Condition 1: Creator is the user
+ if ($creator_id === $u_id) {
+ $booked_slots[] = $meeting_time;
+ break;
+ }
+
+ // Condition 2: User is a participant with status 0 or 1
+ if (isset($participant_ids[$u_id]) && in_array($participant_ids[$u_id], [0, 1], true)) {
+ $booked_slots[] = $meeting_time;
+ break;
+ }
+ }
+ }
+
+ // Step 4: Build combined slot list
+ $combined_slots = [];
+ foreach ($common_slots as $slot) {
+ $combined_slots[] = [
+ 'time' => $slot,
+ 'is_booked' => in_array($slot, $booked_slots, true),
+ ];
+ }
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => count($combined_slots) ? 'Common availability slots retrieved successfully.' : 'No common slots found.',
+ 'data' => [
+ 'event_id' => $event_id,
+ 'date' => $date,
+ 'common_slots' => $combined_slots,
+ ],
+ ], 200);
+ }
public function get_matchmaking_settings(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
From 62b1b8858023b34cd3aa862563894917e0821a91 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 7 Aug 2025 16:43:16 +0530
Subject: [PATCH 101/171] #182 Changes in Match making APIs due to changes in
database table changes
---
includes/wpem-rest-authentication.php | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index 49bcb2e..58e5ef8 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -723,25 +723,25 @@ public function perform_user_authentication($request) {
// Get matchmaking data from user meta instead of custom table
$matchmaking_details = array(
'attendeeId' => $user_id,
- 'firstName' => $first_name,
- 'lastName' => $last_name,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
'email' => $user_email,
- 'profilePhoto' => get_user_meta($user_id, '_profile_photo', true) ?: '',
+ 'profile_photo' => get_user_meta($user_id, '_profile_photo', true) ?: '',
'profession' => get_user_meta($user_id, '_profession', true) ?: '',
'experience' => get_user_meta($user_id, '_experience', true) ?: '',
- 'companyName' => get_user_meta($user_id, '_company_name', true) ?: '',
+ 'company_name' => get_user_meta($user_id, '_company_name', true) ?: '',
'country' => get_user_meta($user_id, '_country', true) ?: '',
'city' => get_user_meta($user_id, '_city', true) ?: '',
'about' => get_user_meta($user_id, '_about', true) ?: '',
'skills' => maybe_unserialize(get_user_meta($user_id, '_skills', true)) ?: [],
'interests' => maybe_unserialize(get_user_meta($user_id, '_interests', true)) ?: [],
- 'organizationName' => get_user_meta($user_id, '_organization_name', true) ?: '',
- 'organizationLogo' => get_user_meta($user_id, '_organization_logo', true) ?: '',
- 'organizationCity' => get_user_meta($user_id, '_organization_city', true) ?: '',
- 'organizationCountry' => get_user_meta($user_id, '_organization_country', true) ?: '',
- 'organizationDescription' => get_user_meta($user_id, 'organization_description', true) ?: '',
- 'messageNotification' => get_user_meta($user_id, '_message_notification', true) ?: '',
- 'approveProfileStatus' => get_user_meta($user_id, '_approve_profile_status', true) ?: '',
+ 'organization_name' => get_user_meta($user_id, '_organization_name', true) ?: '',
+ 'organization_logo' => get_user_meta($user_id, '_organization_logo', true) ?: '',
+ 'organization_city' => get_user_meta($user_id, '_organization_city', true) ?: '',
+ 'organization_country' => get_user_meta($user_id, '_organization_country', true) ?: '',
+ 'organization_description' => get_user_meta($user_id, 'organization_description', true) ?: '',
+ 'message_notification' => get_user_meta($user_id, '_message_notification', true) ?: '',
+ 'approve_profile_status' => get_user_meta($user_id, '_approve_profile_status', true) ?: '',
);
$data['user']['matchmaking_details'] = $matchmaking_details;
From 8efcc23b3dceb2cf28fa15e002f0a550f7912d24 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 7 Aug 2025 17:12:30 +0530
Subject: [PATCH 102/171] #182 Changes in Match making APIs due to changes in
database table changes
---
includes/wpem-rest-matchmaking-create-meetings.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index fef1663..6b85c8e 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -185,7 +185,7 @@ public function create_meeting(WP_REST_Request $request) {
$participant_details[] = [
'name' => $participant_name,
'profession' => $participant_meta['_profession'][0] ?? '',
- 'profile_picture' => esc_url($profile_picture)
+ 'profile_photo' => esc_url($profile_picture)
];
// Email to participant
From c93c61dd90945537adc9fd3d4e890f0a42254699 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 7 Aug 2025 17:27:17 +0530
Subject: [PATCH 103/171] #182 Changes in Match making APIs due to changes in
database table changes
---
includes/wpem-rest-matchmaking-create-meetings.php | 8 ++++----
includes/wpem-rest-matchmaking-profile.php | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 6b85c8e..e7882e8 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -330,9 +330,9 @@ public function get_user_meetings(WP_REST_Request $request) {
'id' => (int)$pid,
'status' => (int)$status,
'name' => $display_name,
- 'image' => !empty($profile_photo) ? esc_url($profile_photo) : '',
+ 'profile_photo' => !empty($profile_photo) ? esc_url($profile_photo) : '',
'profession' => !empty($profession) ? esc_html($profession) : '',
- 'company' => !empty($company_name) ? esc_html($company_name) : '',
+ 'company_name' => !empty($company_name) ? esc_html($company_name) : '',
];
}
@@ -353,9 +353,9 @@ public function get_user_meetings(WP_REST_Request $request) {
$host_info = [
'id' => $host_id,
'name' => $host_display_name,
- 'image' => !empty($host_profile_photo) ? esc_url($host_profile_photo) : '',
+ 'profile_photo' => !empty($host_profile_photo) ? esc_url($host_profile_photo) : '',
'profession' => !empty($host_profession) ? esc_html($host_profession) : '',
- 'company' => !empty($host_company_name) ? esc_html($host_company_name) : '',
+ 'company_name' => !empty($host_company_name) ? esc_html($host_company_name) : '',
];
$meeting_data[] = [
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 6224c1a..c7517df 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -344,7 +344,7 @@ public function upload_user_file($request) {
'status' => 'OK',
'message' => 'File uploaded and stored successfully.',
'data' => [
- 'file_url' => $file_url,
+ 'profile_photo' => $file_url,
'meta_updated' => true
]
], 200);
From 3c6eeb6a6ab115be1a1b8c20ed51fd016bd35d75 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 7 Aug 2025 18:50:08 +0530
Subject: [PATCH 104/171] #188 Organization information not coming in login and
attendee-profile api
---
includes/wpem-rest-authentication.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index 58e5ef8..e72a21b 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -739,7 +739,7 @@ public function perform_user_authentication($request) {
'organization_logo' => get_user_meta($user_id, '_organization_logo', true) ?: '',
'organization_city' => get_user_meta($user_id, '_organization_city', true) ?: '',
'organization_country' => get_user_meta($user_id, '_organization_country', true) ?: '',
- 'organization_description' => get_user_meta($user_id, 'organization_description', true) ?: '',
+ 'organization_description' => get_user_meta($user_id, '_organization_description', true) ?: '',
'message_notification' => get_user_meta($user_id, '_message_notification', true) ?: '',
'approve_profile_status' => get_user_meta($user_id, '_approve_profile_status', true) ?: '',
);
From 0e018bccc453d0e8d095048574abe8d853a8eb9f Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 8 Aug 2025 10:03:33 +0530
Subject: [PATCH 105/171] #187 In user-registered-events Send only those events
for which attendee is registered
---
...rest-matchmaking-user-registred-events.php | 110 ++++++++++--------
1 file changed, 64 insertions(+), 46 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-registred-events.php b/includes/wpem-rest-matchmaking-user-registred-events.php
index c4e4dae..d7ef37d 100644
--- a/includes/wpem-rest-matchmaking-user-registred-events.php
+++ b/includes/wpem-rest-matchmaking-user-registred-events.php
@@ -29,58 +29,76 @@ public function register_routes() {
}
public function get_user_registered_events($request) {
- $target_user_id = intval($request->get_param('user_id'));
+ $target_user_id = intval($request->get_param('user_id'));
- $args = array(
- 'post_type' => 'event_registration',
- 'posts_per_page' => -1,
- 'post_status' => 'any',
- 'fields' => 'ids',
- 'post_author' => $target_user_id,
- );
+ // Get user's email from ID
+ $user_info = get_userdata($target_user_id);
+ if (!$user_info) {
+ return new WP_REST_Response(array(
+ 'code' => 404,
+ 'status' => 'ERROR',
+ 'message' => 'User not found.',
+ 'data' => []
+ ), 404);
+ }
- $query = new WP_Query($args);
- $event_ids = array();
+ $user_email = $user_info->user_email;
- foreach ($query->posts as $registration_id) {
- $event_id = wp_get_post_parent_id($registration_id);
- if (!empty($event_id) && !in_array($event_id, $event_ids)) {
- $event_ids[] = (int) $event_id;
- }
- }
+ // Get all event registrations where attendee email matches
+ $args = array(
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'meta_query' => array(
+ array(
+ 'key' => '_attendee_email',
+ 'value' => $user_email,
+ 'compare' => '='
+ )
+ )
+ );
- if (empty($event_ids)) {
- return new WP_REST_Response(array(
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No registered events found.',
- 'data' => []
- ), 200);
- }
+ $query = new WP_Query($args);
- $events = array();
- foreach ($event_ids as $event_id) {
- $post = get_post($event_id);
- if ($post && $post->post_type === 'event_listing') {
- $events[] = array(
- 'event_id' => $event_id,
- 'title' => get_the_title($event_id),
- 'status' => $post->post_status,
- 'start_date' => get_post_meta($event_id, '_event_start_date', true),
- 'end_date' => get_post_meta($event_id, '_event_end_date', true),
- 'location' => get_post_meta($event_id, '_event_location', true),
- 'banner' => get_post_meta($event_id, '_event_banner', true),
- );
- }
- }
+ $event_ids = array();
+ foreach ($query->posts as $registration_post) {
+ $event_id = wp_get_post_parent_id($registration_post->ID);
+ if (!empty($event_id) && !in_array($event_id, $event_ids)) {
+ $event_ids[] = (int) $event_id;
+ }
+ }
- return new WP_REST_Response(array(
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Events retrieved successfully.',
- 'data' => $events
- ), 200);
- }
+ if (empty($event_ids)) {
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'No registered events found.',
+ 'data' => []
+ ), 200);
+ }
+
+ $events = array();
+ foreach ($event_ids as $event_id) {
+ $post = get_post($event_id);
+ if ($post && $post->post_type === 'event_listing') {
+ $events[] = array(
+ 'event_id' => $event_id,
+ 'title' => get_the_title($event_id),
+ 'status' => $post->post_status,
+ 'start_date' => get_post_meta($event_id, '_event_start_date', true),
+ 'end_date' => get_post_meta($event_id, '_event_end_date', true),
+ 'location' => get_post_meta($event_id, '_event_location', true),
+ 'banner' => get_post_meta($event_id, '_event_banner', true),
+ );
+ }
+ }
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Events retrieved successfully.',
+ 'data' => $events
+ ), 200);
+ }
}
new WPEM_REST_User_Registered_Events_Controller();
From 8ee7ce6bda23caf4440bcc4d23459d0645bcf5c2 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 8 Aug 2025 15:19:37 +0530
Subject: [PATCH 106/171] #190 In Filter-user api don't send user's own
information
---
includes/wpem-rest-matchmaking-filter-users.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 3c54975..d8cd872 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -230,6 +230,9 @@ public function handle_filter_users($request) {
// Step 2: Build the full user data from usermeta
$users_data = [];
foreach ($registered_user_ids as $uid) {
+ if($uid == $user_id){
+ continue;
+ }
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
From 7c3d84155a6d890e99b6258b70b4b49b9e2f99a8 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 8 Aug 2025 15:23:42 +0530
Subject: [PATCH 107/171] #190 In Filter-user api don't send user's own
information
---
includes/wpem-rest-matchmaking-filter-users.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index d8cd872..34dc996 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -247,8 +247,8 @@ public function handle_filter_users($request) {
'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => get_user_meta($uid, '_skills', true),
- 'interests' => get_user_meta($uid, '_interests', true),
+ 'skills' => maybe_unserialize(get_user_meta($uid, '_skills', true)),
+ 'interests' => maybe_unserialize(get_user_meta($uid, '_interests', true)),
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
'organization_logo' => get_user_meta($uid, '_organization_logo', true),
From 0f4d5b526a401017bfd71edbe36a20af0c3b7ecb Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 8 Aug 2025 15:41:32 +0530
Subject: [PATCH 108/171] #189 In get-message api need image in seperate key
---
.../wpem-rest-matchmaking-user-messages.php | 146 ++----------------
1 file changed, 17 insertions(+), 129 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 44b9391..4318c4f 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -217,6 +217,23 @@ public function handle_get_messages($request) {
$sender_id, $receiver_id, $receiver_id, $sender_id,
$per_page, $offset
), ARRAY_A);
+ // Separate text and image
+ foreach ($messages as &$msg) {
+ $msg['text'] = null;
+ $msg['image'] = null;
+
+ // Break message into lines
+ $parts = preg_split("/\n+/", trim($msg['message']));
+
+ foreach ($parts as $part) {
+ $part = trim($part);
+ if (filter_var($part, FILTER_VALIDATE_URL) && preg_match('/\.(jpg|jpeg|png|gif|webp)$/i', $part)) {
+ $msg['image'] = $part;
+ } elseif (!empty($part)) {
+ $msg['text'] = isset($msg['text']) && $msg['text'] ? $msg['text'] . " " . $part : $part;
+ }
+ }
+ }
$total_pages = ceil($total_messages / $per_page);
@@ -233,135 +250,6 @@ public function handle_get_messages($request) {
]
], 200);
}
- /*public function handle_get_conversation_list($request) {
- global $wpdb;
-
- $user_id = intval($request->get_param('user_id'));
- $event_ids = $request->get_param('event_ids'); // expects an array
- $paged = max(1, intval($request->get_param('paged')));
- $per_page = max(1, intval($request->get_param('per_page')));
-
- if (empty($user_id) || empty($event_ids) || !is_array($event_ids)) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'Bad Request',
- 'message' => 'user_id and event_ids[] are required.',
- ], 400);
- }
-
- $postmeta = $wpdb->postmeta;
- $messages_tbl = $wpdb->prefix . 'wpem_matchmaking_users_messages';
-
- // Step 1: Get users registered in the same events (excluding self)
- $event_placeholders = implode(',', array_fill(0, count($event_ids), '%d'));
- $registered_user_ids = $wpdb->get_col($wpdb->prepare("
- SELECT DISTINCT pm2.meta_value
- FROM $postmeta pm1
- INNER JOIN $postmeta pm2 ON pm1.post_id = pm2.post_id
- WHERE pm1.meta_key = '_event_id'
- AND pm1.meta_value IN ($event_placeholders)
- AND pm2.meta_key = '_attendee_user_id'
- AND pm2.meta_value != %d
- ", array_merge($event_ids, [ $user_id ])));
-
- if (empty($registered_user_ids)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No users registered in the same events.',
- 'data' => []
- ], 200);
- }
-
- // Step 2: Get users who have messaged with current user
- $messaged_user_ids = $wpdb->get_col($wpdb->prepare("
- SELECT DISTINCT user_id FROM (
- SELECT sender_id AS user_id FROM $messages_tbl WHERE receiver_id = %d
- UNION
- SELECT receiver_id AS user_id FROM $messages_tbl WHERE sender_id = %d
- ) AS temp
- WHERE user_id != %d
- ", $user_id, $user_id, $user_id));
-
- if (empty($messaged_user_ids)) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No message history found.',
- 'data' => []
- ], 200);
- }
-
- // Step 3: Intersect both lists
- $valid_user_ids = array_values(array_intersect($registered_user_ids, $messaged_user_ids));
-
- $total_count = count($valid_user_ids);
- if ($total_count === 0) {
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'No matched users found.',
- 'data' => [
- 'total_users' => 0,
- 'current_page' => $paged,
- 'total_pages' => 0,
- 'users' => []
- ]
- ], 200);
- }
-
- // Step 4: Paginate
- $offset = ($paged - 1) * $per_page;
- $paginated_ids = array_slice($valid_user_ids, $offset, $per_page);
-
- // Step 5: Build user info with last message (using user meta)
- $results = [];
- foreach ($paginated_ids as $uid) {
- // Get last message exchanged
- $last_message_row = $wpdb->get_row($wpdb->prepare("
- SELECT message, created_at
- FROM $messages_tbl
- WHERE (sender_id = %d AND receiver_id = %d) OR (sender_id = %d AND receiver_id = %d)
- ORDER BY created_at DESC
- LIMIT 1
- ", $user_id, $uid, $uid, $user_id));
-
- // Get display name from meta with fallback
- $display_name = get_user_meta($uid, 'display_name', true);
- if (empty($display_name)) {
- $first_name = get_user_meta($uid, 'first_name', true);
- $last_name = get_user_meta($uid, 'last_name', true);
- $display_name = trim("$first_name $last_name");
- }
-
- $results[] = [
- 'user_id' => (int) $uid,
- 'first_name' => get_user_meta($uid, 'first_name', true),
- 'last_name' => get_user_meta($uid, 'last_name', true),
- 'display_name' => $display_name,
- 'profile_photo' => get_user_meta($uid, '_profile_photo', true),
- 'profession' => get_user_meta($uid, '_profession', true),
- 'company_name' => get_user_meta($uid, '_company_name', true),
- 'last_message' => $last_message_row ? $last_message_row->message : null,
- 'message_time' => $last_message_row ? date('Y-m-d H:i:s', strtotime($last_message_row->created_at)) : null,
- ];
- }
-
- $last_page = ceil($total_count / $per_page);
-
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Filtered users retrieved.',
- 'data' => [
- 'total_users' => $total_count,
- 'current_page' => $paged,
- 'per_page' => $per_page,
- 'last_page' => $last_page,
- 'users' => $results
- ]
- ], 200);
- }*/
public function handle_get_conversation_list($request) {
global $wpdb;
From 27dc161b291defdae65cdd1b12d1924d2b1a4cf8 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 11 Aug 2025 12:56:05 +0530
Subject: [PATCH 109/171] #189 In get-message api need image in seperate key
---
includes/wpem-rest-matchmaking-user-messages.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 4318c4f..dea9a50 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -219,20 +219,23 @@ public function handle_get_messages($request) {
), ARRAY_A);
// Separate text and image
foreach ($messages as &$msg) {
- $msg['text'] = null;
$msg['image'] = null;
// Break message into lines
$parts = preg_split("/\n+/", trim($msg['message']));
+ $text_parts = [];
foreach ($parts as $part) {
$part = trim($part);
if (filter_var($part, FILTER_VALIDATE_URL) && preg_match('/\.(jpg|jpeg|png|gif|webp)$/i', $part)) {
$msg['image'] = $part;
} elseif (!empty($part)) {
- $msg['text'] = isset($msg['text']) && $msg['text'] ? $msg['text'] . " " . $part : $part;
+ $text_parts[] = $part;
}
}
+
+ // Replace message with text only
+ $msg['message'] = implode(' ', $text_parts);
}
$total_pages = ceil($total_messages / $per_page);
From 086e27a565af3de374e78f21a3e79101fa7ecd9e Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 11 Aug 2025 16:50:08 +0530
Subject: [PATCH 110/171] #190
---
includes/wpem-rest-matchmaking-profile.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index c7517df..bda9efd 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -101,8 +101,8 @@ public function get_attendee_profile($request) {
'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => isset($user_meta['_skills'][0]) ? maybe_unserialize($user_meta['_skills'][0]) : array(),
- 'interests' => isset($user_meta['_interests'][0]) ? maybe_unserialize($user_meta['_interests'][0]) : array(),
+ 'skills' => isset($user_meta['_skills'][0]) ? (array) maybe_unserialize($user_meta['_skills'][0]) : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? (array) maybe_unserialize($user_meta['_interests'][0]) : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
@@ -143,8 +143,8 @@ public function get_attendee_profile($request) {
'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => isset($user_meta['_skills'][0]) ? maybe_unserialize($user_meta['_skills'][0]) : array(),
- 'interests' => isset($user_meta['_interests'][0]) ? maybe_unserialize($user_meta['_interests'][0]) : array(),
+ 'skills' => isset($user_meta['_skills'][0]) ? (array) maybe_unserialize($user_meta['_skills'][0]) : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? (array) maybe_unserialize($user_meta['_interests'][0]) : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
From 96be13145f1405355b15b47f38c7bdb7ce0d31ba Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 11 Aug 2025 17:55:03 +0530
Subject: [PATCH 111/171] #191 Meeting APIs Changes
---
includes/wpem-rest-matchmaking-filter-users.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 34dc996..325527d 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -255,6 +255,7 @@ public function handle_filter_users($request) {
'organization_country' => get_user_meta($uid, '_organization_country', true),
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
+ 'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
];
}
From 1fdd03f5bb64d46a243e19bdcf1c15e554f98f15 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 11 Aug 2025 18:35:46 +0530
Subject: [PATCH 112/171] #191
---
includes/wpem-rest-matchmaking-filter-users.php | 4 ++--
includes/wpem-rest-matchmaking-profile.php | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 325527d..33449d1 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -247,8 +247,8 @@ public function handle_filter_users($request) {
'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => maybe_unserialize(get_user_meta($uid, '_skills', true)),
- 'interests' => maybe_unserialize(get_user_meta($uid, '_interests', true)),
+ 'skills' => get_user_meta($uid, '_skills', true),
+ 'interests' => get_user_meta($uid, '_interests', true),
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
'organization_logo' => get_user_meta($uid, '_organization_logo', true),
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index bda9efd..76bf5b0 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -101,8 +101,8 @@ public function get_attendee_profile($request) {
'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => isset($user_meta['_skills'][0]) ? (array) maybe_unserialize($user_meta['_skills'][0]) : array(),
- 'interests' => isset($user_meta['_interests'][0]) ? (array) maybe_unserialize($user_meta['_interests'][0]) : array(),
+ 'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
@@ -143,8 +143,8 @@ public function get_attendee_profile($request) {
'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => isset($user_meta['_skills'][0]) ? (array) maybe_unserialize($user_meta['_skills'][0]) : array(),
- 'interests' => isset($user_meta['_interests'][0]) ? (array) maybe_unserialize($user_meta['_interests'][0]) : array(),
+ 'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
From 12384a65c17bae7224a184cdd2cb5290ec9fd04c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Mon, 11 Aug 2025 18:37:01 +0530
Subject: [PATCH 113/171] #191
---
includes/wpem-rest-authentication.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index e72a21b..b35c574 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -733,8 +733,8 @@ public function perform_user_authentication($request) {
'country' => get_user_meta($user_id, '_country', true) ?: '',
'city' => get_user_meta($user_id, '_city', true) ?: '',
'about' => get_user_meta($user_id, '_about', true) ?: '',
- 'skills' => maybe_unserialize(get_user_meta($user_id, '_skills', true)) ?: [],
- 'interests' => maybe_unserialize(get_user_meta($user_id, '_interests', true)) ?: [],
+ 'skills' => get_user_meta($user_id, '_skills', true) ?: [],
+ 'interests' => get_user_meta($user_id, '_interests', true) ?: [],
'organization_name' => get_user_meta($user_id, '_organization_name', true) ?: '',
'organization_logo' => get_user_meta($user_id, '_organization_logo', true) ?: '',
'organization_city' => get_user_meta($user_id, '_organization_city', true) ?: '',
From 91323699e2035881e66cef269f62fdff77e6702e Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 12 Aug 2025 19:13:09 +0530
Subject: [PATCH 114/171] #193 Need api changes in related apis visibility
setting
---
includes/wpem-rest-matchmaking-profile.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 76bf5b0..9966f4f 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -109,6 +109,7 @@ public function get_attendee_profile($request) {
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : ''
+ 'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0
);
return new WP_REST_Response(array(
@@ -150,7 +151,8 @@ public function get_attendee_profile($request) {
'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
- 'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : ''
+ 'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
+ 'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0
);
}
From e3217b083733d24078c9b8041cf5dcf8a029b76c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 12 Aug 2025 22:45:35 +0530
Subject: [PATCH 115/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-matchmaking-profile.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 9966f4f..d5faef1 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -108,7 +108,7 @@ public function get_attendee_profile($request) {
'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
- 'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : ''
+ 'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0
);
From 8d1d62be91876ae5605ecd0b858373cbbc96aa1e Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 13 Aug 2025 11:21:41 +0530
Subject: [PATCH 116/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-matchmaking-profile.php | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index d5faef1..f3c6724 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -197,16 +197,10 @@ public function update_attendee_profile($request) {
];
// Handle normal meta fields
+
foreach ($meta_fields as $field) {
-
if ($request->get_param($field) !== null) {
$value = $request->get_param($field);
-
- // Special handling for array fields
- if (in_array($field, ['skills', 'interests'])) {
- $value = maybe_serialize((array)$value);
- }
-
update_user_meta($user_id, '_'.$field, $value);
}
}
From ad47292903fda74ef5b23c5e8beea85cd7cdd622 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 13 Aug 2025 11:31:11 +0530
Subject: [PATCH 117/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-matchmaking-profile.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index f3c6724..4f502fa 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -105,7 +105,7 @@ public function get_attendee_profile($request) {
'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
- 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
+ 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? $user_meta['_organization_logo'][0] : '',
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
@@ -148,7 +148,7 @@ public function get_attendee_profile($request) {
'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
- 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : array(),
+ 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : '',
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
@@ -233,7 +233,7 @@ public function update_attendee_profile($request) {
$movefile = wp_handle_upload($_FILES['organization_logo'], $upload_overrides);
if (isset($movefile['url'])) {
- update_user_meta($user_id, '_organization_logo', [$movefile['url']]);
+ update_user_meta($user_id, '_organization_logo', esc_url_raw($movefile['url']));
} else {
return new WP_REST_Response([
'code' => 500,
@@ -242,7 +242,7 @@ public function update_attendee_profile($request) {
], 500);
}
} elseif ($request->get_param('organization_logo')) {
- update_user_meta($user_id, '_organization_logo', $request->get_param('organization_logo'));
+ update_user_meta($user_id, '_organization_logo', esc_url_raw($request->get_param('organization_logo')));
}
// Update basic WP user fields
From b532c29e5aa32af468a590322b11d91e11b4c28b Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 13 Aug 2025 13:09:46 +0530
Subject: [PATCH 118/171] #194 add user setting to the Get profile api
---
includes/wpem-rest-matchmaking-profile.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 4f502fa..161608e 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -110,6 +110,7 @@ public function get_attendee_profile($request) {
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0
+ 'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval',
);
return new WP_REST_Response(array(
@@ -152,7 +153,8 @@ public function get_attendee_profile($request) {
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
- 'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0
+ 'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0,
+ 'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval'
);
}
From 53043dd363b71706c4d4067fd2dcfbd82f20948c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 13 Aug 2025 15:41:39 +0530
Subject: [PATCH 119/171] #192 Please Check Payload format and response of
this Listed apis
---
.../wpem-rest-matchmaking-filter-users.php | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 33449d1..ec85287 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -233,6 +233,16 @@ public function handle_filter_users($request) {
if($uid == $user_id){
continue;
}
+ $photo = get_user_meta( $uid, '_profile_photo', true );
+ $photo = maybe_unserialize( $photo );
+ if (is_array($photo)) {
+ $photo = reset($photo); // get first value in the array
+ }
+ $organization_logo = get_user_meta( $uid, '_organization_logo', true );
+ $organization_logo = maybe_unserialize( $organization_logo );
+ if (is_array($organization_logo)) {
+ $organization_logo = reset($organization_logo); // get first value in the array
+ }
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
@@ -240,18 +250,18 @@ public function handle_filter_users($request) {
'last_name' => get_user_meta($uid, 'last_name', true),
'email' => get_userdata($uid)->user_email,
'matchmaking_profile' => get_user_meta($uid, '_matchmaking_profile', true),
- 'profile_photo' => get_user_meta($uid, '_profile_photo', true),
+ 'profile_photo' => $photo,
'profession' => get_user_meta($uid, '_profession', true),
'experience' => get_user_meta($uid, '_experience', true),
'company_name' => get_user_meta($uid, '_company_name', true),
'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => get_user_meta($uid, '_skills', true),
- 'interests' => get_user_meta($uid, '_interests', true),
+ 'skills' => maybe_serialize(get_user_meta($uid, '_skills', true)),
+ 'interests' => maybe_serialize(get_user_meta($uid, '_interests', true)),
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
- 'organization_logo' => get_user_meta($uid, '_organization_logo', true),
+ 'organization_logo' => $organization_logo,
'organization_country' => get_user_meta($uid, '_organization_country', true),
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
From b272627441f0ad1aef92b8253f837e2d2770b2c3 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 12:03:11 +0530
Subject: [PATCH 120/171] #195 User Profile image and organaizationlogo not
coming when registering for new user
---
.../wpem-rest-matchmaking-filter-users.php | 6 +-----
includes/wpem-rest-matchmaking-profile.php | 21 ++++++++++++++-----
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index ec85287..9487eab 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -233,11 +233,7 @@ public function handle_filter_users($request) {
if($uid == $user_id){
continue;
}
- $photo = get_user_meta( $uid, '_profile_photo', true );
- $photo = maybe_unserialize( $photo );
- if (is_array($photo)) {
- $photo = reset($photo); // get first value in the array
- }
+ $photo = get_wpem_user_profile_photo($uid);
$organization_logo = get_user_meta( $uid, '_organization_logo', true );
$organization_logo = maybe_unserialize( $organization_logo );
if (is_array($organization_logo)) {
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 161608e..7abe73b 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -85,7 +85,12 @@ public function get_attendee_profile($request) {
// Get all user meta
$user_meta = get_user_meta($attendee_id);
-
+ $photo = get_wpem_user_profile_photo($attendee_id);
+ $organization_logo = get_user_meta( $attendee_id, '_organization_logo', true );
+ $organization_logo = maybe_unserialize( $organization_logo );
+ if (is_array($organization_logo)) {
+ $organization_logo = reset($organization_logo); // get first value in the array
+ }
// Format the profile data
$profile = array(
'user_id' => $attendee_id,
@@ -94,7 +99,7 @@ public function get_attendee_profile($request) {
'last_name' => isset($user_meta['last_name'][0]) ? sanitize_text_field($user_meta['last_name'][0]) : '',
'email' => $user->user_email,
'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
- 'profile_photo' => isset($user_meta['_profile_photo'][0]) ? esc_url($user_meta['_profile_photo'][0]) : '',
+ 'profile_photo' => $photo,
'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
@@ -105,7 +110,7 @@ public function get_attendee_profile($request) {
'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
- 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? $user_meta['_organization_logo'][0] : '',
+ 'organization_logo' => $organization_logo,
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
@@ -131,6 +136,12 @@ public function get_attendee_profile($request) {
$profiles = array();
foreach ($users as $user) {
$user_meta = get_user_meta($user->ID);
+ $photo = get_wpem_user_profile_photo($user->ID);
+ $organization_logo = get_user_meta($user->ID, '_organization_logo', true);
+ $organization_logo = maybe_unserialize($organization_logo);
+ if (is_array($organization_logo)) {
+ $organization_logo = reset($organization_logo);
+ }
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
@@ -138,7 +149,7 @@ public function get_attendee_profile($request) {
'last_name' => isset($user_meta['last_name'][0]) ? sanitize_text_field($user_meta['last_name'][0]) : '',
'email' => $user->user_email,
'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
- 'profile_photo' => isset($user_meta['_profile_photo'][0]) ? esc_url($user_meta['_profile_photo'][0]) : '',
+ 'profile_photo' => $photo,
'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
@@ -149,7 +160,7 @@ public function get_attendee_profile($request) {
'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
- 'organization_logo' => isset($user_meta['_organization_logo'][0]) ? maybe_unserialize($user_meta['_organization_logo'][0]) : '',
+ 'organization_logo' => $organization_logo,
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
From a40665c6db97794db52af107fc435ea5bdbb86be Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 12:10:12 +0530
Subject: [PATCH 121/171] #193 Need api changes in related apis visibility
setting
---
includes/wpem-rest-matchmaking-filter-users.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 9487eab..4db1e6b 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -262,6 +262,7 @@ public function handle_filter_users($request) {
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
+ 'approve_profile_status' => get_user_meta($uid, '_approve_profile_status', true), // participant activation setting
];
}
From 61b2c21203c36687def4729cd6f18ed6d38d12fc Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 12:25:37 +0530
Subject: [PATCH 122/171] #197 In Conversation api send last_message_has_image
flag if last message has image
---
includes/wpem-rest-matchmaking-user-messages.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index dea9a50..9462298 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -327,6 +327,11 @@ public function handle_get_conversation_list($request) {
$display_name = trim("$first_name $last_name");
}
+ $is_image = 0;
+ if ($last_message_row && preg_match('/\.(jpg|jpeg|png|gif|webp)$/i', $last_message_row->message)) {
+ $is_image = 1;
+ }
+
$results[] = [
'user_id' => (int) $partner_id,
'first_name' => get_user_meta($partner_id, 'first_name', true),
@@ -337,6 +342,7 @@ public function handle_get_conversation_list($request) {
'company_name' => get_user_meta($partner_id, '_company_name', true),
'last_message' => $last_message_row ? $last_message_row->message : null,
'message_time' => $last_message_row ? date('Y-m-d H:i:s', strtotime($last_message_row->created_at)) : null,
+ 'last_message_is_image' => $is_image,
];
}
From 2bdbb24eea3c22c4ef235db62253102a1f7c25c4 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 13:23:09 +0530
Subject: [PATCH 123/171] #196 Need API for matchmaking setting GET and POST
---
.../wpem-rest-matchmaking-user-settings.php | 198 ++++++++++++++++++
wpem-rest-api.php | 1 +
2 files changed, 199 insertions(+)
create mode 100644 includes/wpem-rest-matchmaking-user-settings.php
diff --git a/includes/wpem-rest-matchmaking-user-settings.php b/includes/wpem-rest-matchmaking-user-settings.php
new file mode 100644
index 0000000..4c2419c
--- /dev/null
+++ b/includes/wpem-rest-matchmaking-user-settings.php
@@ -0,0 +1,198 @@
+namespace,
+ '/matchmaking-attendee-settings',
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array($this, 'get_matchmaking_attendee_settings'),
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
+ 'args' => array(
+ 'user_id' => array(
+ 'required' => false,
+ 'type' => 'integer'
+ ),
+ 'event_id' => array(
+ 'required' => false,
+ 'type' => 'integer'
+ )
+ ),
+ )
+ );
+
+ // POST - Update settings
+ register_rest_route(
+ $this->namespace,
+ '/update-matchmaking-attendee-settings',
+ array(
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array($this, 'update_matchmaking_attendee_settings'),
+ 'permission_callback' => array($auth_controller, 'check_authentication'),
+ 'args' => array(
+ 'user_id' => array(
+ 'required' => false,
+ 'type' => 'integer'
+ ),
+ 'enable_matchmaking' => array(
+ 'required' => false,
+ 'type' => 'integer'
+ ),
+ 'message_notification' => array(
+ 'required' => false,
+ 'type' => 'integer'
+ ),
+ 'meeting_request_mode' => array(
+ 'required' => false,
+ 'type' => 'string'
+ ),
+ 'event_participation' => array(
+ 'required' => false,
+ 'type' => 'array'
+ )
+ ),
+ )
+ );
+ }
+
+ public function get_matchmaking_attendee_settings($request) {
+ $user_id = $request->get_param('user_id') ?: get_current_user_id();
+ $event_id = (int) $request->get_param('event_id');
+
+ $user = get_user_by('id', $user_id);
+ if (!$user) {
+ return new WP_REST_Response(array(
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'User not found.',
+ 'data' => null
+ ), 404);
+ }
+
+ $user_event_participation = [];
+
+ if ($event_id) {
+ // Get registrations for specific event
+ $registration_post_ids = get_posts([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'post_status' => 'any',
+ 'author' => $user_id,
+ 'post_parent' => $event_id,
+ 'fields' => 'ids',
+ ]);
+
+ if (!empty($registration_post_ids)) {
+ $create_matchmaking = (int) get_post_meta($registration_post_ids[0], '_create_matchmaking', true);
+ $user_event_participation[] = [
+ 'event_id' => $event_id,
+ 'create_matchmaking' => $create_matchmaking
+ ];
+ }
+ } else {
+ // Get all registrations for this user
+ $user_registrations = get_posts([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'post_status' => 'any',
+ 'author' => $user_id,
+ 'fields' => 'ids',
+ ]);
+
+ foreach ($user_registrations as $registration_id) {
+ $parent_event_id = (int) get_post_field('post_parent', $registration_id);
+ if (!$parent_event_id) {
+ continue;
+ }
+ $create_matchmaking = (int) get_post_meta($registration_id, '_create_matchmaking', true);
+ $user_event_participation[] = [
+ 'event_id' => $parent_event_id,
+ 'create_matchmaking' => $create_matchmaking
+ ];
+ }
+ }
+
+ $settings = array(
+ 'enable_matchmaking' => (int) get_user_meta($user_id, '_matchmaking_profile', true)[0],
+ 'message_notification' => (int) get_user_meta($user_id, '_message_notification', true),
+ 'event_participation' => $user_event_participation,
+ 'meeting_request_mode' => get_user_meta($user_id, '_wpem_meeting_request_mode', true) ?: 'approval'
+ );
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Settings retrieved successfully.',
+ 'data' => $settings
+ ), 200);
+ }
+
+ public function update_matchmaking_attendee_settings($request) {
+ $user_id = $request->get_param('user_id') ?: get_current_user_id();
+ $user = get_user_by('id', $user_id);
+
+ if (!$user) {
+ return new WP_REST_Response(array(
+ 'code' => 404,
+ 'status' => 'Not Found',
+ 'message' => 'User not found.',
+ 'data' => null
+ ), 404);
+ }
+
+ // Update user meta
+ if (!is_null($request->get_param('enable_matchmaking'))) {
+ update_user_meta($user_id, '_matchmaking_profile', (int) $request->get_param('enable_matchmaking'));
+ }
+ if (!is_null($request->get_param('message_notification'))) {
+ update_user_meta($user_id, '_message_notification', (int) $request->get_param('message_notification'));
+ }
+ if (!is_null($request->get_param('meeting_request_mode'))) {
+ update_user_meta($user_id, '_wpem_meeting_request_mode', sanitize_text_field($request->get_param('meeting_request_mode')));
+ }
+
+ // Update event participation settings
+ $event_participation = $request->get_param('event_participation');
+ if (is_array($event_participation)) {
+ foreach ($event_participation as $event) {
+ if (!isset($event['event_id'])) {
+ continue;
+ }
+ $eid = (int) $event['event_id'];
+ $value = isset($event['create_matchmaking']) ? (int) $event['create_matchmaking'] : 0;
+
+ $registration_post_ids = get_posts([
+ 'post_type' => 'event_registration',
+ 'posts_per_page' => -1,
+ 'post_status' => 'any',
+ 'author' => $user_id,
+ 'post_parent' => $eid,
+ 'fields' => 'ids',
+ ]);
+
+ foreach ($registration_post_ids as $registration_post_id) {
+ update_post_meta($registration_post_id, '_create_matchmaking', $value);
+ }
+ }
+ }
+
+ return new WP_REST_Response(array(
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Settings updated successfully.',
+ ), 200);
+ }
+}
+
+new WPEM_REST_Attendee_Settings_Controller();
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index 3778acd..edd997e 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -71,6 +71,7 @@ public function __construct() {
include 'includes/wpem-rest-matchmaking-get-texonomy.php';
include 'includes/wpem-rest-matchmaking-user-messages.php';
include 'includes/wpem-rest-matchmaking-filter-users.php';
+ include 'includes/wpem-rest-matchmaking-users-settings.php';
include 'includes/wpem-rest-matchmaking-create-meetings.php';
include 'includes/wpem-rest-matchmaking-user-registred-events.php';
From d63eeba13a9c0d118d5731597d40bad1631f7d5e Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 14:45:53 +0530
Subject: [PATCH 124/171] #198 Pforile Image Not comming in
get-conversation-list api
---
includes/wpem-rest-matchmaking-user-messages.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 9462298..4c1816c 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -331,13 +331,13 @@ public function handle_get_conversation_list($request) {
if ($last_message_row && preg_match('/\.(jpg|jpeg|png|gif|webp)$/i', $last_message_row->message)) {
$is_image = 1;
}
-
+ $photo = get_wpem_user_profile_photo($partner_id);
$results[] = [
'user_id' => (int) $partner_id,
'first_name' => get_user_meta($partner_id, 'first_name', true),
'last_name' => get_user_meta($partner_id, 'last_name', true),
'display_name' => $display_name,
- 'profile_photo' => get_user_meta($partner_id, '_profile_photo', true),
+ 'profile_photo' => $photo,
'profession' => get_user_meta($partner_id, '_profession', true),
'company_name' => get_user_meta($partner_id, '_company_name', true),
'last_message' => $last_message_row ? $last_message_row->message : null,
From 21b0be826e08b325d3780161984f9e92330105a2 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 15:02:02 +0530
Subject: [PATCH 125/171] #199 Organization Website URL not getting from API
---
includes/wpem-rest-matchmaking-profile.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 7abe73b..99ced7d 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -114,6 +114,7 @@ public function get_attendee_profile($request) {
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
+ 'organization_website' => isset($user_meta['organization_website'][0]) ? sanitize_text_field($user_meta['organization_website'][0]) : '',
'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0
'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval',
);
@@ -164,6 +165,7 @@ public function get_attendee_profile($request) {
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
+ 'organization_website' => isset($user_meta['organization_website'][0]) ? sanitize_text_field($user_meta['organization_website'][0]) : '',
'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0,
'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval'
);
From fe637fe405de8786f1be014e5579f5390f85e126 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 15:07:45 +0530
Subject: [PATCH 126/171] #199 Organization Website URL not getting from API
---
includes/wpem-rest-matchmaking-filter-users.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 4db1e6b..085f73b 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -261,6 +261,7 @@ public function handle_filter_users($request) {
'organization_country' => get_user_meta($uid, '_organization_country', true),
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
+ 'organization_website' => get_user_meta($uid, 'organization_website', true),
'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
'approve_profile_status' => get_user_meta($uid, '_approve_profile_status', true), // participant activation setting
];
From f85355247b2f6e67537376f77522204287b9348b Mon Sep 17 00:00:00 2001
From: Rita
Date: Thu, 14 Aug 2025 16:37:38 +0530
Subject: [PATCH 127/171] Coming empty strings array in filter user api for
skills and interest #200
---
.../wpem-rest-matchmaking-filter-users.php | 41 ++++++++++++++++---
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 085f73b..0ea7c3b 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -8,6 +8,10 @@ public function __construct() {
add_action('rest_api_init', array($this, 'register_routes'));
}
+ /**
+ * This function used to register routes
+ * @since 1.1.0
+ */
public function register_routes() {
$auth_controller = new WPEM_REST_Authentication();
// General filter
@@ -43,6 +47,10 @@ public function register_routes() {
));
}
+ /**
+ * This function used to filter users
+ * @since 1.1.0
+ */
public function handle_your_matches($request) {
global $wpdb;
@@ -156,8 +164,13 @@ public function handle_your_matches($request) {
return $response;
}
+ /**
+ * This function used to filter users
+ * @since 1.1.0
+ * @param $request
+ * @return WP_REST_Response
+ */
public function handle_filter_users($request) {
-
global $wpdb;
if (!get_option('enable_matchmaking', false)) {
@@ -207,7 +220,6 @@ public function handle_filter_users($request) {
]);
foreach ($attendee_query->posts as $registration_id) {
-
if (wp_get_post_parent_id($registration_id) == $event_id) {
$uid = get_post_field('post_author', $registration_id);
if ($uid && !in_array($uid, $registered_user_ids)) {
@@ -215,7 +227,6 @@ public function handle_filter_users($request) {
}
}
}
-
}
if (empty($registered_user_ids)) {
@@ -239,6 +250,23 @@ public function handle_filter_users($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo); // get first value in the array
}
+ $skills = get_user_meta($uid, '_skills', true);
+ $interests = get_user_meta($uid, '_interests', true);
+
+ // Remove empty values so [""] becomes []
+ $skills = array_filter((array)$skills, 'strlen');
+ $interests = array_filter((array)$interests, 'strlen');
+
+ // Serialize empty array if nothing remains
+ $skills = !empty($skills) ? maybe_serialize($skills) : serialize(array());
+ $interests = !empty($interests) ? maybe_serialize($interests) : serialize(array());
+
+ $photo = get_wpem_user_profile_photo($uid);
+ $organization_logo = get_user_meta( $uid, '_organization_logo', true );
+ $organization_logo = maybe_unserialize( $organization_logo );
+ if (is_array($organization_logo)) {
+ $organization_logo = reset($organization_logo);
+ }
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
@@ -253,8 +281,8 @@ public function handle_filter_users($request) {
'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => maybe_serialize(get_user_meta($uid, '_skills', true)),
- 'interests' => maybe_serialize(get_user_meta($uid, '_interests', true)),
+ 'skills' => $skills,
+ 'interests' => $interests,
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
'organization_logo' => $organization_logo,
@@ -262,8 +290,9 @@ public function handle_filter_users($request) {
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
'organization_website' => get_user_meta($uid, 'organization_website', true),
+
'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
- 'approve_profile_status' => get_user_meta($uid, '_approve_profile_status', true), // participant activation setting
+ 'approve_profile_status' => get_user_meta($uid, '_approve_profile_status', true),
];
}
From c09541164e1cb65dd2d6f6765e9f50f4c1647cf6 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 14 Aug 2025 16:40:26 +0530
Subject: [PATCH 128/171] #201 organization_website gets empty in filter-user
api
---
includes/wpem-rest-matchmaking-filter-users.php | 2 +-
includes/wpem-rest-matchmaking-profile.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 0ea7c3b..00c6af8 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -289,7 +289,7 @@ public function handle_filter_users($request) {
'organization_country' => get_user_meta($uid, '_organization_country', true),
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
- 'organization_website' => get_user_meta($uid, 'organization_website', true),
+ 'organization_website' => get_user_meta($uid, '_organization_website', true),
'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
'approve_profile_status' => get_user_meta($uid, '_approve_profile_status', true),
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 99ced7d..1b51a9b 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -208,7 +208,7 @@ public function update_attendee_profile($request) {
'profession', 'experience', 'company_name', 'country',
'city', 'about', 'skills', 'interests', 'organization_name',
'organization_logo', 'organization_city', 'organization_country',
- 'organization_description', 'message_notification', 'matchmaking_profile'
+ 'organization_description', 'organization_website', 'message_notification', 'matchmaking_profile'
];
// Handle normal meta fields
From 56f5899f032a9f889e8513dda25fcc75e6d74748 Mon Sep 17 00:00:00 2001
From: Rita
Date: Thu, 14 Aug 2025 16:42:57 +0530
Subject: [PATCH 129/171] organization_website gets empty in filter-user api
#201
---
includes/wpem-rest-matchmaking-profile.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 99ced7d..a3380d2 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -115,7 +115,7 @@ public function get_attendee_profile($request) {
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
'organization_website' => isset($user_meta['organization_website'][0]) ? sanitize_text_field($user_meta['organization_website'][0]) : '',
- 'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0
+ 'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0,
'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval',
);
From b30db59402f528cebe39d657b18fd248bdc8a5b8 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 15 Aug 2025 10:08:11 +0530
Subject: [PATCH 130/171] #192
---
.../wpem-rest-matchmaking-filter-users.php | 15 +++++++++++++-
includes/wpem-rest-matchmaking-profile.php | 20 ++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 00c6af8..1e55e7c 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -267,6 +267,19 @@ public function handle_filter_users($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
+ // Get country value from user meta
+ $country_value = get_user_meta($uid, '_country', true);
+
+ // Inline logic to always get country code
+ $countries = wpem_get_all_countries(); // [code => name]
+ $country_code = $country_value;
+ if (!isset($countries[$country_value])) {
+ // If not a code, try to find code by name
+ $found_code = array_search($country_value, $countries);
+ if ($found_code) {
+ $country_code = $found_code;
+ }
+ }
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
@@ -278,7 +291,7 @@ public function handle_filter_users($request) {
'profession' => get_user_meta($uid, '_profession', true),
'experience' => get_user_meta($uid, '_experience', true),
'company_name' => get_user_meta($uid, '_company_name', true),
- 'country' => get_user_meta($uid, '_country', true),
+ 'country' => $country_code,
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
'skills' => $skills,
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 204c1e9..431ee9d 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -91,6 +91,15 @@ public function get_attendee_profile($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo); // get first value in the array
}
+ $country_value = isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '';
+ $country_code = '';
+ if ($country_value) {
+ if (isset($countries[$country_value])) {
+ $country_code = $country_value;
+ } else {
+ $country_code = array_search($country_value, $countries);
+ }
+ }
// Format the profile data
$profile = array(
'user_id' => $attendee_id,
@@ -103,7 +112,7 @@ public function get_attendee_profile($request) {
'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
- 'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
+ 'country' => $country_code,
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
@@ -143,6 +152,15 @@ public function get_attendee_profile($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
+ $country_value = isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '';
+ $country_code = '';
+ if ($country_value) {
+ if (isset($countries[$country_value])) {
+ $country_code = $country_value;
+ } else {
+ $country_code = array_search($country_value, $countries);
+ }
+ }
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
From 2107ff79a4c9869675221951fea0db12cb237311 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 15:54:08 +0530
Subject: [PATCH 131/171] Profile Photo Not coming in Get Meetings API #204
---
includes/wpem-rest-matchmaking-create-meetings.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index e7882e8..8cc4336 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -322,7 +322,7 @@ public function get_user_meetings(WP_REST_Request $request) {
}
// Get profile data from user meta (assuming these are stored as meta)
- $profile_photo = get_user_meta($pid, '_profile_photo', true);
+ $profile_photo = get_wpem_user_profile_photo($pid);
$profession = get_user_meta($pid, '_profession', true); // Note: Typo in 'profession'?
$company_name = get_user_meta($pid, '_company_name', true);
@@ -346,7 +346,7 @@ public function get_user_meetings(WP_REST_Request $request) {
}
// Get host profile data from user meta
- $host_profile_photo = get_user_meta($host_id, '_profile_photo', true);
+ $host_profile_photo = get_wpem_user_profile_photo($host_id);
$host_profession = get_user_meta($host_id, '_profession', true);
$host_company_name = get_user_meta($host_id, '_company_name', true);
@@ -794,4 +794,4 @@ public function get_matchmaking_settings(WP_REST_Request $request) {
}
}
-new WPEM_REST_Create_Meeting_Controller();
+new WPEM_REST_Create_Meeting_Controller();
\ No newline at end of file
From 442edc90602406cb26c59b7f9146e8052f5acb5e Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 16:14:21 +0530
Subject: [PATCH 132/171] send available_for_meeting key in attendee-profile
api #208
---
includes/wpem-rest-matchmaking-profile.php | 25 +++++++++++++++-------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 431ee9d..6f5cb32 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -70,7 +70,7 @@ public function get_attendee_profile($request) {
}
$attendee_id = $request->get_param('attendeeId');
-
+ $countries = wpem_get_all_countries();
if ($attendee_id) {
// Check if user exists
$user = get_user_by('ID', $attendee_id);
@@ -91,6 +91,7 @@ public function get_attendee_profile($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo); // get first value in the array
}
+
$country_value = isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '';
$country_code = '';
if ($country_value) {
@@ -100,6 +101,9 @@ public function get_attendee_profile($request) {
$country_code = array_search($country_value, $countries);
}
}
+ $meta = get_user_meta($attendee_id, '_available_for_meeting', true);
+ $meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
+
// Format the profile data
$profile = array(
'user_id' => $attendee_id,
@@ -123,9 +127,10 @@ public function get_attendee_profile($request) {
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
- 'organization_website' => isset($user_meta['organization_website'][0]) ? sanitize_text_field($user_meta['organization_website'][0]) : '',
+ 'organization_website' => isset($user_meta['_organization_website'][0]) ? sanitize_text_field($user_meta['_organization_website'][0]) : '',
'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0,
'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval',
+ 'available_for_meeting' => (int)$meeting_available,
);
return new WP_REST_Response(array(
@@ -147,8 +152,8 @@ public function get_attendee_profile($request) {
foreach ($users as $user) {
$user_meta = get_user_meta($user->ID);
$photo = get_wpem_user_profile_photo($user->ID);
- $organization_logo = get_user_meta($user->ID, '_organization_logo', true);
- $organization_logo = maybe_unserialize($organization_logo);
+ $organization_logo = get_user_meta( $user->ID, '_organization_logo', true );
+ $organization_logo = maybe_unserialize( $organization_logo );
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
@@ -161,6 +166,9 @@ public function get_attendee_profile($request) {
$country_code = array_search($country_value, $countries);
}
}
+ $meta = get_user_meta($user->ID, '_available_for_meeting', true);
+ $meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
+
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
@@ -172,7 +180,7 @@ public function get_attendee_profile($request) {
'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
- 'country' => isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '',
+ 'country' => $country_code,
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
@@ -183,9 +191,10 @@ public function get_attendee_profile($request) {
'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
- 'organization_website' => isset($user_meta['organization_website'][0]) ? sanitize_text_field($user_meta['organization_website'][0]) : '',
+ 'organization_website' => isset($user_meta['_organization_website'][0]) ? sanitize_text_field($user_meta['_organization_website'][0]) : '',
'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0,
- 'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval'
+ 'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval',
+ 'available_for_meeting' => (int)$meeting_available,
);
}
@@ -380,4 +389,4 @@ public function upload_user_file($request) {
}
}
-new WPEM_REST_Attendee_Profile_Controller_All();
+new WPEM_REST_Attendee_Profile_Controller_All();
\ No newline at end of file
From 9fd274a304ef0ac4fb53fd1ca558515424c3055d Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 16:37:28 +0530
Subject: [PATCH 133/171] get-availability-slots API issue #207
---
.../wpem-rest-matchmaking-create-meetings.php | 25 +++++++++++--------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 8cc4336..7fd4b49 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -54,7 +54,7 @@ public function register_routes() {
]);
register_rest_route($this->namespace, '/get-availability-slots', [
'methods' => WP_REST_Server::READABLE,
- 'callback' => [$this, 'get_booked_meeting_slots'],
+ 'callback' => [$this, 'get_available_meeting_slots'],
'permission_callback' => [$auth_controller, 'check_authentication'],
'args' => [
'user_id' => [
@@ -606,7 +606,14 @@ public function update_meeting_status(WP_REST_Request $request) {
]
], 200);
}
- public function get_booked_meeting_slots(WP_REST_Request $request) {
+
+ /**
+ * Get available meeting slots
+ * @param WP_REST_Request $request
+ * @return WP_REST_Response
+ * @since 1.1.0
+ */
+ public function get_available_meeting_slots(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
'code' => 403,
@@ -617,21 +624,17 @@ public function get_booked_meeting_slots(WP_REST_Request $request) {
}
$user_id = intval($request->get_param('user_id')) ?: get_current_user_id();
-
- $saved_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
- $available_flag = (int)get_user_meta($user_id, '_available_for_meeting', true);
-
- if (is_array($saved_data)) {
- ksort($saved_data); // sort by date keys
- }
+ $default_slots = get_wpem_default_meeting_slots_for_user($user_id);
+ $meta = get_user_meta($user_id, '_available_for_meeting', true);
+ $meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
'message' => 'Availability slots fetched successfully.',
'data' => [
- 'available_for_meeting' => $available_flag,
- 'slots' => $saved_data
+ 'available_for_meeting' => $meeting_available,
+ 'slots' => $default_slots
]
], 200);
}
From 401dce53628df55be465d88a34ea6ff829cb7913 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 16:53:05 +0530
Subject: [PATCH 134/171] Changes in Login API #209
---
includes/wpem-rest-authentication.php | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index b35c574..0ace47e 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -720,28 +720,43 @@ public function perform_user_authentication($request) {
);
if ($is_matchmaking && $enable_matchmaking) {
+ $user_meta = get_user_meta($user_id);
+ $organization_logo = get_user_meta( $user_id, '_organization_logo', true );
+ $organization_logo = maybe_unserialize( $organization_logo );
+ if (is_array($organization_logo)) {
+ $organization_logo = reset($organization_logo); // get first value in the array
+ }
+ $meta = get_user_meta($user_id, '_available_for_meeting', true);
+ $meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
+
+ $photo = get_wpem_user_profile_photo($user_id);
// Get matchmaking data from user meta instead of custom table
$matchmaking_details = array(
'attendeeId' => $user_id,
'first_name' => $first_name,
'last_name' => $last_name,
- 'email' => $user_email,
- 'profile_photo' => get_user_meta($user_id, '_profile_photo', true) ?: '',
+ 'email' => $user->user_email,
+ 'display_name' => $user->display_name,
+ 'profile_photo' => $photo,
'profession' => get_user_meta($user_id, '_profession', true) ?: '',
'experience' => get_user_meta($user_id, '_experience', true) ?: '',
'company_name' => get_user_meta($user_id, '_company_name', true) ?: '',
'country' => get_user_meta($user_id, '_country', true) ?: '',
'city' => get_user_meta($user_id, '_city', true) ?: '',
'about' => get_user_meta($user_id, '_about', true) ?: '',
- 'skills' => get_user_meta($user_id, '_skills', true) ?: [],
- 'interests' => get_user_meta($user_id, '_interests', true) ?: [],
+ 'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'organization_name' => get_user_meta($user_id, '_organization_name', true) ?: '',
- 'organization_logo' => get_user_meta($user_id, '_organization_logo', true) ?: '',
+ 'organization_logo' => $organization_logo,
'organization_city' => get_user_meta($user_id, '_organization_city', true) ?: '',
'organization_country' => get_user_meta($user_id, '_organization_country', true) ?: '',
'organization_description' => get_user_meta($user_id, '_organization_description', true) ?: '',
'message_notification' => get_user_meta($user_id, '_message_notification', true) ?: '',
'approve_profile_status' => get_user_meta($user_id, '_approve_profile_status', true) ?: '',
+ 'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
+ 'approve_profile_status' => isset($user_meta['_approve_profile_status'][0]) ? (int)$user_meta['_approve_profile_status'][0] : 0,
+ 'wpem_meeting_request_mode' => isset($user_meta['_wpem_meeting_request_mode'][0]) ? $user_meta['_wpem_meeting_request_mode'][0] : 'approval',
+ 'available_for_meeting' => (int)$meeting_available,
);
$data['user']['matchmaking_details'] = $matchmaking_details;
From c6530a4280e98926d3e2620ff728aae3a0e14ac4 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 17:04:40 +0530
Subject: [PATCH 135/171] In Filter User only those attendee's detail should
get whose matchmaking_profile key is 1 #210
---
.../wpem-rest-matchmaking-filter-users.php | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 1e55e7c..dca8c27 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -244,6 +244,9 @@ public function handle_filter_users($request) {
if($uid == $user_id){
continue;
}
+ if(!get_user_meta($uid, '_matchmaking_profile', true)) {
+ continue;
+ }
$photo = get_wpem_user_profile_photo($uid);
$organization_logo = get_user_meta( $uid, '_organization_logo', true );
$organization_logo = maybe_unserialize( $organization_logo );
@@ -267,19 +270,6 @@ public function handle_filter_users($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
- // Get country value from user meta
- $country_value = get_user_meta($uid, '_country', true);
-
- // Inline logic to always get country code
- $countries = wpem_get_all_countries(); // [code => name]
- $country_code = $country_value;
- if (!isset($countries[$country_value])) {
- // If not a code, try to find code by name
- $found_code = array_search($country_value, $countries);
- if ($found_code) {
- $country_code = $found_code;
- }
- }
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
@@ -291,7 +281,7 @@ public function handle_filter_users($request) {
'profession' => get_user_meta($uid, '_profession', true),
'experience' => get_user_meta($uid, '_experience', true),
'company_name' => get_user_meta($uid, '_company_name', true),
- 'country' => $country_code,
+ 'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
'skills' => $skills,
From 9b22c1b10f199f6cf6192b22d21951ba8b9fa5a5 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 17:07:04 +0530
Subject: [PATCH 136/171] Version 1.1.0 improvements #205
---
readme.txt | 11 +++++++++--
wpem-rest-api.php | 6 +++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/readme.txt b/readme.txt
index 5d55b8f..d2b77c7 100755
--- a/readme.txt
+++ b/readme.txt
@@ -3,9 +3,9 @@
Contributors: wpeventmanager,ashokdudhat,krinay
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=55FRYATTFLA5N
Tags: event manager, Event, events, event manager api , listings
-Requires at least: 6.0.1
+Requires at least: 6.5.1
Tested up to: 6.8
-Stable tag: 1.0.10
+Stable tag: 1.1.0
Requires PHP: 8.0.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -120,6 +120,13 @@ If you wish to be notified of new postings on your site you can use a plugin suc
== Changelog ==
+= 1.1.0 [ 19th August 2025 ] =
+
+Fixed : Change the Plugin name
+Fixed : After password change the user will auto logout from mobile app
+Fixed : Without Active license some section of the app will not work
+Added : Match making functionality
+
= 1.0.10 [ 09th May 2025 ] =
Fixed: All events are shown even from other organizers
diff --git a/wpem-rest-api.php b/wpem-rest-api.php
index edd997e..7583465 100644
--- a/wpem-rest-api.php
+++ b/wpem-rest-api.php
@@ -9,10 +9,10 @@
*
* Text Domain: wpem-rest-api
* Domain Path: /languages
-* Version: 1.0.10
+* Version: 1.1.0
* Since: 1.0.0
*
-* Requires WordPress Version at least: 6.0.1
+* Requires WordPress Version at least: 6.5.1
* Copyright: 2019 WP Event Manager
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -40,7 +40,7 @@ public function __construct() {
}
// Define constants
- define( 'WPEM_REST_API_VERSION', '1.0.10' );
+ define( 'WPEM_REST_API_VERSION', '1.1.0' );
define( 'WPEM_REST_API_FILE', __FILE__ );
define( 'WPEM_REST_API_PLUGIN_DIR', untrailingslashit( plugin_dir_path(__FILE__ ) ) );
define( 'WPEM_REST_API_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path(__FILE__) ), basename(__FILE__) ) ) );
From 5c2a323dd2c7203b8aced26ab106744254030581 Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 17:19:32 +0530
Subject: [PATCH 137/171] How to send Skills and Interests in attendee-profile
api when user want to set to [] #211
---
includes/wpem-rest-matchmaking-profile.php | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 6f5cb32..c6572db 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -243,7 +243,20 @@ public function update_attendee_profile($request) {
foreach ($meta_fields as $field) {
if ($request->get_param($field) !== null) {
$value = $request->get_param($field);
- update_user_meta($user_id, '_'.$field, $value);
+ // If it's an array, filter out blanks
+ if (is_array($value)) {
+ $value = array_filter($value, function($v) {
+ return $v !== null && $v !== '';
+ });
+ $value = array_values($value); // reindex after filtering
+ }
+
+ // Only update if not completely empty
+ if (!empty($value)) {
+ update_user_meta($user_id, '_' . $field, $value);
+ } else {
+ update_user_meta($user_id, '_' . $field, ''); // cleanup if blank
+ }
}
}
From 6b08b19393f448c98adb47ca27ab747c8c54e94e Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 18 Aug 2025 17:59:04 +0530
Subject: [PATCH 138/171] Please send time format according to web in meetings
apis #212
---
includes/wpem-rest-matchmaking-create-meetings.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 7fd4b49..3db174c 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -361,8 +361,8 @@ public function get_user_meetings(WP_REST_Request $request) {
$meeting_data[] = [
'meeting_id' => (int)$meeting['id'],
'meeting_date' => date_i18n('l, d F Y', strtotime($meeting['meeting_date'])),
- 'start_time' => date_i18n('h:i A', strtotime($meeting['meeting_start_time'])),
- 'end_time' => date_i18n('h:i A', strtotime($meeting['meeting_end_time'])),
+ 'start_time' => date_i18n('H:i', strtotime($meeting['meeting_start_time'])),
+ 'end_time' => date_i18n('H:i', strtotime($meeting['meeting_end_time'])),
'message' => $meeting['message'],
'host_info' => $host_info,
'participants' => $participants_info,
From 256be1003c501a9db16880abbfb2d67390058f8d Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 13:28:09 +0530
Subject: [PATCH 139/171] #213 Meeting time format shows wrong in meeting
details and mail
---
includes/wpem-rest-matchmaking-create-meetings.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 3db174c..a71e926 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -203,7 +203,7 @@ public function create_meeting(WP_REST_Request $request) {
{$sender_user->display_name} has requested a meeting with you.
Event: {$event_name}
Date: {$formatted_date}
- Time: {$formatted_time} {$timezone_abbr}
+ Time: {$formatted_time}
Company: {$host_company}
City: {$host_city}
Country: {$host_country}
From 80abdca7773364aafb774ed6a5a2c8a0ab0ff9fd Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 14:51:08 +0530
Subject: [PATCH 140/171] #206 Admin : Upload logo for app is not working
---
assets/js/admin.js | 18 ++++++++++++++++++
assets/js/admin.min.js | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/assets/js/admin.js b/assets/js/admin.js
index f0c8896..35c3c8b 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -41,6 +41,24 @@ var WPEMRestAPIAdmin = (function () {
jQuery('#select-events-row').hide();
}
}
+ jQuery('.wp_event_manager_upload_file_button').on('click', function(e){
+ e.preventDefault();
+ var button = jQuery(this);
+ var input = button.closest('.file_url').find('#wpem_rest_api_app_logo');
+ console.log(input);
+ var custom_uploader = wp.media({
+ title: 'Select or Upload Image',
+ button: {
+ text: 'Use this image'
+ },
+ multiple: false
+ })
+ .on('select', function() {
+ var attachment = custom_uploader.state().get('selection').first().toJSON();
+ input.val(attachment.url); // Set image URL in input
+ })
+ .open();
+ });
},
actions: {
saveApiKey: function (e) {
diff --git a/assets/js/admin.min.js b/assets/js/admin.min.js
index e397afc..cb522e9 100644
--- a/assets/js/admin.min.js
+++ b/assets/js/admin.min.js
@@ -1 +1 @@
-var WPEMRestAPIAdmin={init:function(){var e;function a(){"selected"===jQuery('input[name="event_show_by"]:checked').val()?(jQuery("#select-events-row").show(),jQuery("#select_events").chosen("destroy").chosen()):jQuery("#select-events-row").hide()}jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("#select_events").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click((function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()})),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click((function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")})),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout((function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())}),500)}}),a(),jQuery('input[name="event_show_by"]').change((function(){a()}))},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1,event_show_by:jQuery('input[name="event_show_by"]:checked').val(),select_events:jQuery("#select_events").val()||[],mobile_menu:jQuery('input[name="mobile_menu[]"]:checked').map((function(){return this.value})).get()},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
"),e.data.mobile_menu&&(jQuery('input[name="mobile_menu[]"]').prop("checked",!1),e.data.mobile_menu.forEach((function(e){jQuery('input[name="mobile_menu[]"][value="'+e+'"]').prop("checked",!0)})))},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready((function(e){WPEMRestAPIAdmin.init()}));
\ No newline at end of file
+var WPEMRestAPIAdmin={init:function(){var e;function a(){"selected"===jQuery('input[name="event_show_by"]:checked').val()?(jQuery("#select-events-row").show(),jQuery("#select_events").chosen("destroy").chosen()):jQuery("#select-events-row").hide()}jQuery("#update_api_key").on("click",WPEMRestAPIAdmin.actions.saveApiKey),jQuery("select#key_user").chosen(),jQuery("select#event_id").chosen(),jQuery("#select_events").chosen(),jQuery("input#date_expires").datepicker({dateFormat:"yy-mm-dd",minDate:0}),jQuery("table#app-branding-color-dark").hide(),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-light-mode").click(function(){jQuery(".wpem-app-branding-mode").removeClass("wpem-dark-mode").addClass("wpem-light-mode"),jQuery("table#app-branding-color").show(),jQuery("table#app-branding-color-dark").hide()}),jQuery(".wpem-app-branding-mode .app-branding-mode .wpem-dark-mode").click(function(){jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show(),jQuery(".wpem-app-branding-mode").removeClass("wpem-light-mode").addClass("wpem-dark-mode")}),jQuery("#update_app_branding").on("click",WPEMRestAPIAdmin.actions.saveAppBranding),jQuery(".wpem-colorpicker").wpColorPicker({defaultColor:!0,change:function(a,r){a.target,clearTimeout(e),e=setTimeout(function(){WPEMRestAPIAdmin.actions.changeBrightness(a,r.toString())},500)}}),a(),jQuery('input[name="event_show_by"]').change(function(){a()}),jQuery(".wp_event_manager_upload_file_button").on("click",function(e){e.preventDefault();var a=jQuery(this).closest(".file_url").find("#wpem_rest_api_app_logo");console.log(a);var r=wp.media({title:"Select or Upload Image",button:{text:"Use this image"},multiple:!1}).on("select",function(){var e=r.state().get("selection").first().toJSON();a.val(e.url)}).open()})},actions:{saveApiKey:function(e){e.preventDefault();var a=this;jQuery("#api_key_loader").show(),jQuery("#update_api_key").attr("disabled",!0),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_rest_api_keys",security:wpem_rest_api_admin.save_api_nonce,key_id:jQuery("#key_id").val(),description:jQuery("#key_description").val(),user:jQuery("#key_user").val(),permissions:jQuery("#key_permissions").val(),event_id:jQuery("#event_id").val(),date_expires:jQuery("#date_expires").val(),restrict_check_in:jQuery('input[name="restrict_check_in"]').attr("checked")?0:1,event_show_by:jQuery('input[name="event_show_by"]:checked').val(),select_events:jQuery("#select_events").val()||[],mobile_menu:jQuery('input[name="mobile_menu[]"]:checked').map(function(){return this.value}).get()},beforeSend:function(e){},success:function(e){e.success?(jQuery("h2, h3",a.el).first().html('"),0'+e.errorThrown+"
"),e.data.mobile_menu&&(jQuery('input[name="mobile_menu[]"]').prop("checked",!1),e.data.mobile_menu.forEach(function(e){jQuery('input[name="mobile_menu[]"][value="'+e+'"]').prop("checked",!0)}))},error:function(e,r,n){jQuery("h2, h3",a.el).first().append('")},complete:function(e,a){jQuery("#api_key_loader").hide(),jQuery("#update_api_key").attr("disabled",!1)}})},saveAppBranding:function(e){e.preventDefault();var a="",r=jQuery("#app-branding-color").is(":visible"),n=jQuery("#app-branding-color-dark").is(":visible");r?a="light":n&&(a="dark"),jQuery.ajax({type:"POST",url:wpem_rest_api_admin.ajaxUrl,data:{action:"save_app_branding",security:wpem_rest_api_admin.save_app_branding_nonce,wpem_primary_color:jQuery('input[name="wpem_primary_color"]').val(),wpem_success_color:jQuery('input[name="wpem_success_color"]').val(),wpem_info_color:jQuery('input[name="wpem_info_color"]').val(),wpem_warning_color:jQuery('input[name="wpem_warning_color"]').val(),wpem_danger_color:jQuery('input[name="wpem_danger_color"]').val(),wpem_primary_dark_color:jQuery('input[name="wpem_primary_dark_color"]').val(),wpem_success_dark_color:jQuery('input[name="wpem_success_dark_color"]').val(),wpem_info_dark_color:jQuery('input[name="wpem_info_dark_color"]').val(),wpem_warning_dark_color:jQuery('input[name="wpem_warning_dark_color"]').val(),wpem_danger_dark_color:jQuery('input[name="wpem_danger_dark_color"]').val(),active_mode:a},beforeSend:function(e){},success:function(e){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has been successfully saved.
'),"dark"==e.data.mode&&(jQuery("table#app-branding-color").hide(),jQuery("table#app-branding-color-dark").show())},error:function(e,a,r){jQuery(".wpem-branding-status").html('"),jQuery(".update_app_branding_message").html(' Your preferred color for your app branding has not been successfully saved.
')},complete:function(e,a){}})},changeBrightness:function(e,a){var r=e.target.name,n=jQuery(e.target).parents("table").attr("id");jQuery.ajax({url:wpem_rest_api_admin.ajaxUrl,type:"POST",dataType:"HTML",data:{action:"change_brighness_color",color:a},success:function(e){const a=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");jQuery("#"+n+" tbody tr td#"+r).html(a)}})}}};jQuery(document).ready(function(e){WPEMRestAPIAdmin.init()});
\ No newline at end of file
From 0fb41814ff656b7344ce62ce899708db83072965 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 15:28:08 +0530
Subject: [PATCH 141/171] #202 When send chat message then it will send mail
---
.../wpem-rest-matchmaking-user-messages.php | 64 +++++++++++++------
1 file changed, 45 insertions(+), 19 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 4c1816c..559c6f4 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -64,7 +64,7 @@ public function handle_send_message($request) {
$text_message = sanitize_textarea_field($request->get_param('message'));
// Get minimal user objects just for email addresses
- $sender_user = get_user_by('id', $sender_id);
+ $sender_user = get_user_by('id', $sender_id);
$receiver_user = get_user_by('id', $receiver_id);
if (!$sender_user || !$receiver_user) {
@@ -76,22 +76,16 @@ public function handle_send_message($request) {
}
// Get other user data from meta
- $sender_display_name = get_user_meta($sender_id, 'display_name', true);
- if (empty($sender_display_name)) {
- $first_name = get_user_meta($sender_id, 'first_name', true);
- $last_name = get_user_meta($sender_id, 'last_name', true);
- $sender_display_name = trim("$first_name $last_name");
- }
+ $sender_first = get_user_meta($sender_id, 'first_name', true);
+ $sender_last = get_user_meta($sender_id, 'last_name', true);
+ $sender_display_name = trim("$sender_first $sender_last");
- $receiver_display_name = get_user_meta($receiver_id, 'display_name', true);
- if (empty($receiver_display_name)) {
- $first_name = get_user_meta($receiver_id, 'first_name', true);
- $last_name = get_user_meta($receiver_id, 'last_name', true);
- $receiver_display_name = trim("$first_name $last_name");
- }
+ $receiver_first = get_user_meta($receiver_id, 'first_name', true);
+ $receiver_last = get_user_meta($receiver_id, 'last_name', true);
+ $receiver_display_name = trim("$receiver_first $receiver_last");
- // Get notification preferences (assuming stored in meta)
- $sender_notify = get_user_meta($sender_id, '_message_notification', true);
+ // Get notification preferences
+ $sender_notify = get_user_meta($sender_id, '_message_notification', true);
$receiver_notify = get_user_meta($receiver_id, '_message_notification', true);
if ($sender_notify != 1 || $receiver_notify != 1) {
@@ -126,6 +120,7 @@ public function handle_send_message($request) {
], 400);
}
+ // Insert into DB
$table = $wpdb->prefix . 'wpem_matchmaking_users_messages';
$first_message_id = $wpdb->get_var($wpdb->prepare(
"SELECT id FROM $table
@@ -147,14 +142,45 @@ public function handle_send_message($request) {
$insert_id = $wpdb->insert_id;
- // Use email from user object
+ // --- EMAIL SECTION ---
+ $headers = ['Content-Type: text/html; charset=UTF-8'];
+
+ // Build email body for receiver (your format)
+ $receiver_body = "Hello, this is a message from {$sender_first} ";
+ $receiver_body .= "First Name: {$sender_first} ";
+ $receiver_body .= "Last Name: {$sender_last} ";
+ $receiver_body .= "Message: " . nl2br(esc_html($text_message)) . " ";
+ if ($image_url) {
+ $receiver_body .= "
";
+ }
+ $receiver_body .= "Thank you.";
+
wp_mail(
$receiver_user->user_email,
- 'New Message from ' . $sender_display_name,
- $final_message,
- ['Content-Type: text/plain; charset=UTF-8']
+ 'New Message from ' . $sender_first,
+ $receiver_body,
+ $headers
);
+ // Build confirmation email for sender
+ $sender_body = "Hello, this is a confirmation of your message to {$receiver_first} ";
+ $sender_body .= "First Name: {$sender_first} ";
+ $sender_body .= "Last Name: {$sender_last} ";
+ $sender_body .= "Message: " . nl2br(esc_html($text_message)) . " ";
+ if ($image_url) {
+ $sender_body .= "
";
+ }
+ $sender_body .= "Thank you.";
+
+ wp_mail(
+ $sender_user->user_email,
+ 'Your Message to ' . $receiver_first,
+ $sender_body,
+ $headers
+ );
+
+ // --- END EMAIL SECTION ---
+
return new WP_REST_Response([
'code' => 200,
'status' => 'OK',
From 423a0d87d24537632373eb0e032c1c9a4e622c8a Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 16:04:25 +0530
Subject: [PATCH 142/171] #213 Meeting time format shows wrong in meeting
details and mail
---
.../wpem-rest-matchmaking-create-meetings.php | 354 +++++++++++-------
1 file changed, 212 insertions(+), 142 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index a71e926..2ba6913 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -108,158 +108,228 @@ public function register_routes() {
]);
}
public function create_meeting(WP_REST_Request $request) {
- if (!get_option('enable_matchmaking', false)) {
- return new WP_REST_Response([
- 'code' => 403,
- 'status' => 'Disabled',
- 'message' => 'Matchmaking functionality is not enabled.',
- 'data' => null
- ], 403);
- }
+ if (!get_option('enable_matchmaking', false)) {
+ return new WP_REST_Response([
+ 'code' => 403,
+ 'status' => 'Disabled',
+ 'message' => 'Matchmaking functionality is not enabled.',
+ 'data' => null
+ ], 403);
+ }
- global $wpdb;
+ global $wpdb;
- $user_id = intval($request->get_param('user_id'));
- $event_id = intval($request->get_param('event_id'));
- $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
- $slot = sanitize_text_field($request->get_param('slot'));
- $participants = $request->get_param('meeting_participants');
- $message = sanitize_textarea_field($request->get_param('write_a_message'));
-
- if (
- !$user_id || !get_userdata($user_id) ||
- empty($meeting_date) || empty($slot) ||
- empty($participants) || !is_array($participants)
- ) {
- return new WP_REST_Response([
- 'code' => 400,
- 'status' => 'Bad Request',
- 'message' => 'Missing or invalid parameters.',
- 'data' => []
- ], 400);
- }
+ $user_id = intval($request->get_param('user_id'));
+ $event_id = intval($request->get_param('event_id'));
+ $meeting_date = sanitize_text_field($request->get_param('meeting_date'));
+ $slot = sanitize_text_field($request->get_param('slot'));
+ $participants = $request->get_param('meeting_participants');
+ $message = sanitize_textarea_field($request->get_param('write_a_message'));
+
+ if (
+ !$user_id || !get_userdata($user_id) ||
+ empty($meeting_date) || empty($slot) ||
+ empty($participants) || !is_array($participants)
+ ) {
+ return new WP_REST_Response([
+ 'code' => 400,
+ 'status' => 'Bad Request',
+ 'message' => 'Missing or invalid parameters.',
+ 'data' => []
+ ], 400);
+ }
- // Filter out the user themselves from participant list
- $participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
- $participants = array_fill_keys($participants, -1); // -1 = pending
-
- $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
- $inserted = $wpdb->insert($table, [
- 'user_id' => $user_id,
- 'event_id' => $event_id,
- 'participant_ids' => serialize($participants),
- 'meeting_date' => $meeting_date,
- 'meeting_start_time' => $slot,
- 'meeting_end_time' => date("H:i", strtotime($slot . " +1 hour")),
- 'message' => $message,
- 'meeting_status' => 0
- ], ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']);
-
- if (!$inserted) {
- return new WP_REST_Response([
- 'code' => 500,
- 'status' => 'Internal Server Error',
- 'message' => 'Could not create meeting.',
- 'data' => []
- ], 500);
- }
+ // Filter out the user themselves from participant list
+ $participants = array_filter(array_map('intval', $participants), fn($pid) => $pid !== $user_id);
+ $participants = array_fill_keys($participants, -1); // -1 = pending
+
+ $table = $wpdb->prefix . 'wpem_matchmaking_users_meetings';
+ $inserted = $wpdb->insert($table, [
+ 'user_id' => $user_id,
+ 'event_id' => $event_id,
+ 'participant_ids' => serialize($participants),
+ 'meeting_date' => $meeting_date,
+ 'meeting_start_time' => date("H:i", strtotime($slot)), // 24-hour
+ 'meeting_end_time' => date("H:i", strtotime($slot . " +1 hour")), // 24-hour
+ 'message' => $message,
+ 'meeting_status' => 0
+ ], ['%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d']);
+
+ if (!$inserted) {
+ return new WP_REST_Response([
+ 'code' => 500,
+ 'status' => 'Internal Server Error',
+ 'message' => 'Could not create meeting.',
+ 'data' => []
+ ], 500);
+ }
- $meeting_id = $wpdb->insert_id;
- $formatted_date = date("l, d F Y", strtotime($meeting_date));
- $formatted_time = date("h:i A", strtotime($slot));
- $sender_user = get_userdata($user_id);
-
- $participant_details = [];
-
- if (!empty($participants)) {
- foreach (array_keys($participants) as $participant_id) {
- $participant_user = get_userdata($participant_id);
- if (!$participant_user) continue;
-
- $participant_meta = get_user_meta($participant_id);
-
- $participant_name = $participant_user->display_name ?? 'User';
- $participant_email = $participant_user->user_email ?? '';
- $profile_picture = $participant_meta['_profile_photo'][0] ?? EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
-
- $participant_details[] = [
- 'name' => $participant_name,
- 'profession' => $participant_meta['_profession'][0] ?? '',
- 'profile_photo' => esc_url($profile_picture)
- ];
-
- // Email to participant
- $host_meta = get_user_meta($user_id);
- $host_company = $host_meta['_company_name'][0] ?? '';
- $host_city = $host_meta['_city'][0] ?? '';
- $all_countries = wpem_get_all_countries();
- $host_country = $all_countries[$host_meta['_country'][0]] ?? '';
- $event_name = get_the_title($event_id) ?: '';
- $timezone_abbr = wp_timezone_string();
-
- $subject = "{$sender_user->display_name} requested a meeting with you";
- $body = "
- Hello {$participant_name},
- {$sender_user->display_name} has requested a meeting with you.
- Event: {$event_name}
- Date: {$formatted_date}
- Time: {$formatted_time}
- Company: {$host_company}
- City: {$host_city}
- Country: {$host_country}
- Message: {$message}
- ";
-
- wp_mail($participant_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
- }
- }
+ $meeting_id = $wpdb->insert_id;
+ $formatted_date = date("l, d F Y", strtotime($meeting_date));
+ //$formatted_time = date("H:i", strtotime($slot)) ; // 24-hour
+ $start_time = date("H:i", strtotime($slot));
+ $end_time = date("H:i", strtotime($slot . " +1 hour"));
- // Email to sender
- $participant_names = implode(', ', array_column($participant_details, 'name'));
- wp_mail(
- $sender_user->user_email,
- 'Your Meeting Request Has Been Sent',
- "
- Hello {$sender_user->display_name},
- Your meeting request has been sent to: {$participant_names} .
- Date: {$formatted_date}
- Time: {$formatted_time}
- Message: {$message}
- ",
- ['Content-Type: text/html; charset=UTF-8']
- );
+ $formatted_time = $start_time . ' to ' . $end_time;
+ $sender_user = get_userdata($user_id);
- // Update booked slot (2) for the host only
- $slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
- if (!is_array($slot_data)) {
- $slot_data = [];
- }
+ $participant_details = [];
- if (!isset($slot_data[$event_id])) {
- $slot_data[$event_id] = [];
- }
- if (!isset($slot_data[$event_id][$meeting_date])) {
- $slot_data[$event_id][$meeting_date] = [];
- }
+ if (!empty($participants)) {
+ foreach (array_keys($participants) as $participant_id) {
+ $participant_user = get_userdata($participant_id);
+ if (!$participant_user) continue;
- // Set slot as 2 (booked)
- $slot_data[$event_id][$meeting_date][$slot] = 2;
+ $participant_meta = get_user_meta($participant_id);
+
+ $participant_name = $participant_user->display_name ?? 'User';
+ $participant_email = $participant_user->user_email ?? '';
+ $profile_picture = $participant_meta['_profile_photo'][0] ?? EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
- // Update user meta for host only
- update_user_meta($user_id, '_meeting_availability_slot', $slot_data);
+ $participant_details[] = [
+ 'name' => $participant_name,
+ 'profession' => $participant_meta['_profession'][0] ?? '',
+ 'profile_photo' => esc_url($profile_picture)
+ ];
- return new WP_REST_Response([
- 'code' => 200,
- 'status' => 'OK',
- 'message' => 'Meeting created and emails sent!',
- 'data' => [
- 'meeting_date' => $formatted_date,
- 'time' => $formatted_time,
- 'participants' => $participant_details,
- 'message' => $message
- ]
- ], 200);
- }
+ // Email to participant
+ $host_meta = get_user_meta($user_id);
+ $host_company = $host_meta['_company_name'][0] ?? '';
+ $host_city = $host_meta['_city'][0] ?? '';
+ $all_countries = wpem_get_all_countries();
+ $host_country = $all_countries[$host_meta['_country'][0]] ?? '';
+ $event_name = get_the_title($event_id) ?: '';
+ $status_text = "Pending";
+ $meeting_description = $message;
+ $company_name = $participant_meta['_company_name'][0] ?? '';
+ $participant_city = $participant_meta['_city'][0] ?? '';
+ $participant_country = $all_countries[$participant_meta['_country'][0]] ?? '';
+ $profession = (object) ['name' => $participant_meta['_profession'][0] ?? ''];
+
+ // Action buttons
+ $calendar_button = "Add to Calendar ";
+ $view_meeting_button = "View Meeting ";
+
+ $subject = "{$sender_user->display_name} requested a meeting with you";
+
+ // Styled HTML email body
+ $body = sprintf(
+ wp_kses(
+ __(
+ "
+
+
+
+ New Meeting Request
+
+
+
+
Hello %1\$s,
+
%2\$s has requested a meeting with you.
+
+
Meeting Information
+
Event: %3\$s
+
Date: %16\$s
+
Time: %4\$s
+
+
Host Details
+
Name: %2\$s
+ Company: %5\$s
+ City: %6\$s
+ Country: %7\$s
+
+
Receiver (You)
+
Name: %1\$s
+ Title: %8\$s
+ Organization: %9\$s
+ Location: %10\$s, %11\$s
+ Status: %12\$s
+
+
Message: %13\$s
+
+
%14\$s %15\$s
+
+
+
",
+ 'wp-event-manager-registrations'
+ ),
+ [
+ 'div' => ['style' => true],
+ 'p' => ['style' => true],
+ 'strong' => [],
+ 'br' => [],
+ 'h3' => ['style' => true],
+ 'h4' => ['style' => true],
+ 'a' => ['href' => true, 'target' => true, 'style' => true]
+ ]
+ ),
+ esc_html($participant_name),
+ esc_html($sender_user->display_name),
+ esc_html($event_name),
+ esc_html($formatted_time),
+ esc_html($host_company),
+ esc_html($host_city),
+ esc_html($host_country),
+ esc_html($profession->name ?? ''),
+ esc_html($company_name),
+ esc_html($participant_city),
+ esc_html($participant_country),
+ esc_html($status_text),
+ nl2br(esc_html($meeting_description)),
+ $calendar_button,
+ $view_meeting_button,
+ esc_html($formatted_date)
+ );
+
+ // Allow custom filter
+ $body = apply_filters(
+ 'wpem_registration_meeting_request_email_body',
+ $body,
+ $sender_user,
+ $participant_user,
+ $event_name,
+ $formatted_time,
+ $host_company,
+ $host_city,
+ $host_country,
+ $profession,
+ $company_name,
+ $participant_city,
+ $participant_country,
+ $status_text,
+ $meeting_description
+ );
+
+ wp_mail($participant_email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
+ }
+ }
+
+ // Update booked slot (same as before)
+ $slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+ if (!is_array($slot_data)) {
+ $slot_data = [];
+ }
+ if (!isset($slot_data[$event_id])) {
+ $slot_data[$event_id] = [];
+ }
+ if (!isset($slot_data[$event_id][$meeting_date])) {
+ $slot_data[$event_id][$meeting_date] = [];
+ }
+ $slot_data[$event_id][$meeting_date][$slot] = 2;
+ update_user_meta($user_id, '_meeting_availability_slot', $slot_data);
+
+ return new WP_REST_Response([
+ 'code' => 200,
+ 'status' => 'OK',
+ 'message' => 'Meeting created and styled emails sent!',
+ 'data' => [
+ 'meeting_date' => $formatted_date,
+ 'time' => $formatted_time,
+ 'participants' => $participant_details,
+ 'message' => $message
+ ]
+ ], 200);
+ }
public function get_user_meetings(WP_REST_Request $request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response([
From 9e4fe8bad007bdf68af5f17f322991a10fbd752d Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 17:17:32 +0530
Subject: [PATCH 143/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-matchmaking-profile.php | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index c6572db..46f6bc3 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -103,7 +103,20 @@ public function get_attendee_profile($request) {
}
$meta = get_user_meta($attendee_id, '_available_for_meeting', true);
$meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
-
+ // Get all profession terms [slug => name]
+ $professions = get_event_registration_taxonomy_list('event_registration_professions');
+
+ // Get saved profession value
+ $profession_value = isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '';
+ $profession_slug = $profession_value;
+
+ // If it's a name, convert to slug
+ if ($profession_value && !isset($professions[$profession_value])) {
+ $found_slug = array_search($profession_value, $professions);
+ if ($found_slug) {
+ $profession_slug = $found_slug;
+ }
+ }
// Format the profile data
$profile = array(
'user_id' => $attendee_id,
@@ -113,7 +126,7 @@ public function get_attendee_profile($request) {
'email' => $user->user_email,
'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
'profile_photo' => $photo,
- 'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
+ 'profession' => $profession_slug,
'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
'country' => $country_code,
From 145bf009b93125ae24c5d9fbd0d9ffa37eca8831 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 17:21:46 +0530
Subject: [PATCH 144/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-matchmaking-profile.php | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 46f6bc3..36a75a7 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -181,7 +181,16 @@ public function get_attendee_profile($request) {
}
$meta = get_user_meta($user->ID, '_available_for_meeting', true);
$meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
-
+ // Profession slug logic
+ $professions = get_event_registration_taxonomy_list('event_registration_professions');
+ $profession_value = isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '';
+ $profession_slug = $profession_value;
+ if ($profession_value && !isset($professions[$profession_value])) {
+ $found_slug = array_search($profession_value, $professions);
+ if ($found_slug) {
+ $profession_slug = $found_slug;
+ }
+ }
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
@@ -190,7 +199,7 @@ public function get_attendee_profile($request) {
'email' => $user->user_email,
'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
'profile_photo' => $photo,
- 'profession' => isset($user_meta['_profession'][0]) ? sanitize_text_field($user_meta['_profession'][0]) : '',
+ 'profession' => $profession_slug,
'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
'country' => $country_code,
From a803bac6495a99e1e5e442fc80e289015024b3c1 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 17:37:21 +0530
Subject: [PATCH 145/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-matchmaking-profile.php | 74 ++++++++++++++++++++--
1 file changed, 70 insertions(+), 4 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 36a75a7..2d0f717 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -117,6 +117,40 @@ public function get_attendee_profile($request) {
$profession_slug = $found_slug;
}
}
+ // Convert skills (names or IDs) to slugs
+ $skills_slugs = array();
+ if (!empty($user_meta['_skills'][0])) {
+ $skills = maybe_unserialize($user_meta['_skills'][0]);
+ if (is_array($skills)) {
+ foreach ($skills as $skill) {
+ $term = get_term_by('name', $skill, 'event_registration_skills');
+ if (!$term) {
+ $term = get_term_by('id', $skill, 'event_registration_skills');
+ }
+ if ($term) {
+ $skills_slugs[] = $term->slug;
+ }
+ }
+ }
+ }
+
+ // Convert interests (names or IDs) to slugs
+ $interests_slugs = array();
+ if (!empty($user_meta['_interests'][0])) {
+ $interests = maybe_unserialize($user_meta['_interests'][0]);
+ if (is_array($interests)) {
+ foreach ($interests as $interest) {
+ $term = get_term_by('name', $interest, 'event_registration_interests');
+ if (!$term) {
+ $term = get_term_by('id', $interest, 'event_registration_interests');
+ }
+ if ($term) {
+ $interests_slugs[] = $term->slug;
+ }
+ }
+ }
+ }
+
// Format the profile data
$profile = array(
'user_id' => $attendee_id,
@@ -132,8 +166,8 @@ public function get_attendee_profile($request) {
'country' => $country_code,
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
- 'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
+ 'skills' => maybe_serialize($skills_slugs),
+ 'interests' => maybe_serialize($interests_slugs),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => $organization_logo,
@@ -191,6 +225,38 @@ public function get_attendee_profile($request) {
$profession_slug = $found_slug;
}
}
+ // Convert skills (names or IDs) to slugs
+ $skills_slugs = array();
+ if (!empty($user_meta['_skills'][0])) {
+ $skills = maybe_unserialize($user_meta['_skills'][0]);
+ if (is_array($skills)) {
+ foreach ($skills as $skill) {
+ $term = get_term_by('name', $skill, 'event_registration_skills');
+ if (!$term) {
+ $term = get_term_by('id', $skill, 'event_registration_skills');
+ }
+ if ($term) {
+ $skills_slugs[] = $term->slug;
+ }
+ }
+ }
+ }
+ // Convert interests (names or IDs) to slugs
+ $interests_slugs = array();
+ if (!empty($user_meta['_interests'][0])) {
+ $interests = maybe_unserialize($user_meta['_interests'][0]);
+ if (is_array($interests)) {
+ foreach ($interests as $interest) {
+ $term = get_term_by('name', $interest, 'event_registration_interests');
+ if (!$term) {
+ $term = get_term_by('id', $interest, 'event_registration_interests');
+ }
+ if ($term) {
+ $interests_slugs[] = $term->slug;
+ }
+ }
+ }
+ }
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
@@ -205,8 +271,8 @@ public function get_attendee_profile($request) {
'country' => $country_code,
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
- 'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
+ 'skills' => maybe_serialize($skills_slugs),
+ 'interests' => maybe_serialize($interests_slugs),
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => $organization_logo,
From 5bbedf5b80f2b12576754b8cf28cc960fb79fd91 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 17:50:17 +0530
Subject: [PATCH 146/171] #216 In chat image sent from other participant shows
URL
---
includes/wpem-rest-matchmaking-user-messages.php | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-user-messages.php b/includes/wpem-rest-matchmaking-user-messages.php
index 559c6f4..495c82c 100644
--- a/includes/wpem-rest-matchmaking-user-messages.php
+++ b/includes/wpem-rest-matchmaking-user-messages.php
@@ -196,7 +196,7 @@ public function handle_send_message($request) {
]
], 200);
}
- public function handle_get_messages($request) {
+ public function handle_get_messages($request) {
global $wpdb;
if (!get_option('enable_matchmaking', false)) {
@@ -245,8 +245,6 @@ public function handle_get_messages($request) {
), ARRAY_A);
// Separate text and image
foreach ($messages as &$msg) {
- $msg['image'] = null;
-
// Break message into lines
$parts = preg_split("/\n+/", trim($msg['message']));
$text_parts = [];
@@ -275,12 +273,15 @@ public function handle_get_messages($request) {
'current_page' => $page,
'last_page' => $total_pages,
'total_pages' => $total_pages,
- 'messages' => $messages,
+ 'messages' => array_filter($messages, function ($msg) {
+ unset($msg['image']);
+ return $msg;
+ }),
]
], 200);
}
public function handle_get_conversation_list($request) {
- global $wpdb;
+ global $wpdb;
$user_id = intval($request->get_param('user_id'));
$paged = max(1, intval($request->get_param('paged')));
From d8c8d287e9ca68f9bce1c43260a1d0c47109a324 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 18:30:13 +0530
Subject: [PATCH 147/171] #192 Please Check Payload format and response of this
Listed apis
---
.../wpem-rest-matchmaking-filter-users.php | 47 +++++++++++++++++--
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index dca8c27..da68ec5 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -270,6 +270,46 @@ public function handle_filter_users($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
+ // Get taxonomy lists
+ $profession_terms = get_event_registration_taxonomy_list('event_registration_professions'); // [slug => name]
+ $skills_terms = get_event_registration_taxonomy_list('event_registration_skills');
+ $interests_terms = get_event_registration_taxonomy_list('event_registration_interests');
+
+ // Profession slug
+ $profession_value = get_user_meta($uid, '_profession', true);
+ $profession_slug = $profession_value;
+ if ($profession_value && !isset($profession_terms[$profession_value])) {
+ $found_slug = array_search($profession_value, $profession_terms);
+ if ($found_slug) {
+ $profession_slug = $found_slug;
+ }
+ }
+
+ // Skills slugs
+ $skills_raw = get_user_meta($uid, '_skills', true);
+ $skills_arr = is_array($skills_raw) ? $skills_raw : maybe_unserialize($skills_raw);
+ $skills_slugs = [];
+ foreach ((array)$skills_arr as $skill) {
+ if ($skill && !isset($skills_terms[$skill])) {
+ $found_slug = array_search($skill, $skills_terms);
+ $skills_slugs[] = $found_slug ? $found_slug : $skill;
+ } else {
+ $skills_slugs[] = $skill;
+ }
+ }
+
+ // Interests slugs
+ $interests_raw = get_user_meta($uid, '_interests', true);
+ $interests_arr = is_array($interests_raw) ? $interests_raw : maybe_unserialize($interests_raw);
+ $interests_slugs = [];
+ foreach ((array)$interests_arr as $interest) {
+ if ($interest && !isset($interests_terms[$interest])) {
+ $found_slug = array_search($interest, $interests_terms);
+ $interests_slugs[] = $found_slug ? $found_slug : $interest;
+ } else {
+ $interests_slugs[] = $interest;
+ }
+ }
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
@@ -278,14 +318,14 @@ public function handle_filter_users($request) {
'email' => get_userdata($uid)->user_email,
'matchmaking_profile' => get_user_meta($uid, '_matchmaking_profile', true),
'profile_photo' => $photo,
- 'profession' => get_user_meta($uid, '_profession', true),
+ 'profession' => $profession_slug,
'experience' => get_user_meta($uid, '_experience', true),
'company_name' => get_user_meta($uid, '_company_name', true),
'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => $skills,
- 'interests' => $interests,
+ 'skills' => maybe_serialize($skills_slugs),
+ 'interests' => maybe_serialize($interests_slugs),
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
'organization_logo' => $organization_logo,
@@ -293,7 +333,6 @@ public function handle_filter_users($request) {
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
'organization_website' => get_user_meta($uid, '_organization_website', true),
-
'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
'approve_profile_status' => get_user_meta($uid, '_approve_profile_status', true),
];
From d22fd5f4c16beb2c4aa726a68f8e22849ccabd4a Mon Sep 17 00:00:00 2001
From: Roshani
Date: Tue, 19 Aug 2025 18:51:17 +0530
Subject: [PATCH 148/171] #215 Not able to create meeting
---
includes/wpem-rest-matchmaking-create-meetings.php | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 2ba6913..1df875a 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -186,9 +186,21 @@ public function create_meeting(WP_REST_Request $request) {
$participant_email = $participant_user->user_email ?? '';
$profile_picture = $participant_meta['_profile_photo'][0] ?? EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
+ // Get all profession terms [slug => name]
+ $profession_terms = get_event_registration_taxonomy_list('event_registration_professions');
+ // Get saved profession value
+ $profession_value = $participant_meta['_profession'][0] ?? '';
+ $profession_slug = $profession_value;
+ // If it's a name, convert to slug
+ if ($profession_value && !isset($profession_terms[$profession_value])) {
+ $found_slug = array_search($profession_value, $profession_terms);
+ if ($found_slug) {
+ $profession_slug = $found_slug;
+ }
+ }
$participant_details[] = [
'name' => $participant_name,
- 'profession' => $participant_meta['_profession'][0] ?? '',
+ 'profession' => $profession_slug,
'profile_photo' => esc_url($profile_picture)
];
From 8ef46b85a7134f4ec9794c725d3e8340299b337c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 20 Aug 2025 18:28:03 +0530
Subject: [PATCH 149/171] #200 Coming empty strings array in filter user api
for skills and interest
---
.../wpem-rest-matchmaking-filter-users.php | 101 ++++++++----------
1 file changed, 44 insertions(+), 57 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index da68ec5..a44fc62 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -182,17 +182,17 @@ public function handle_filter_users($request) {
], 403);
}
- $event_id = intval($request->get_param('event_id'));
+ $event_id = intval($request->get_param('event_id'));
$user_id = intval($request->get_param('user_id'));
- // Step 1: Get all registered user IDs for this event (from post_parent)
+ // Step 1: Validate registration
$registered_user_ids = [];
if ($event_id && $user_id) {
$registration_query = new WP_Query([
'post_type' => 'event_registration',
'posts_per_page' => -1,
'fields' => 'ids',
- 'post_author' => $user_id,
+ 'post_author' => $user_id,
]);
$has_registration = false;
@@ -212,7 +212,7 @@ public function handle_filter_users($request) {
], 403);
}
- // Now get all users for this event
+ // Collect all registered users for this event
$attendee_query = new WP_Query([
'post_type' => 'event_registration',
'posts_per_page' => -1,
@@ -221,9 +221,9 @@ public function handle_filter_users($request) {
foreach ($attendee_query->posts as $registration_id) {
if (wp_get_post_parent_id($registration_id) == $event_id) {
- $uid = get_post_field('post_author', $registration_id);
+ $uid = intval(get_post_field('post_author', $registration_id));
if ($uid && !in_array($uid, $registered_user_ids)) {
- $registered_user_ids[] = intval($uid);
+ $registered_user_ids[] = $uid;
}
}
}
@@ -238,46 +238,28 @@ public function handle_filter_users($request) {
], 200);
}
- // Step 2: Build the full user data from usermeta
+ // Step 2: Build user data
+ $profession_terms = get_event_registration_taxonomy_list('event_registration_professions'); // [slug => name]
+ $skills_terms = get_event_registration_taxonomy_list('event_registration_skills');
+ $interests_terms = get_event_registration_taxonomy_list('event_registration_interests');
+
$users_data = [];
foreach ($registered_user_ids as $uid) {
- if($uid == $user_id){
- continue;
- }
- if(!get_user_meta($uid, '_matchmaking_profile', true)) {
- continue;
- }
- $photo = get_wpem_user_profile_photo($uid);
- $organization_logo = get_user_meta( $uid, '_organization_logo', true );
- $organization_logo = maybe_unserialize( $organization_logo );
- if (is_array($organization_logo)) {
- $organization_logo = reset($organization_logo); // get first value in the array
- }
- $skills = get_user_meta($uid, '_skills', true);
- $interests = get_user_meta($uid, '_interests', true);
-
- // Remove empty values so [""] becomes []
- $skills = array_filter((array)$skills, 'strlen');
- $interests = array_filter((array)$interests, 'strlen');
-
- // Serialize empty array if nothing remains
- $skills = !empty($skills) ? maybe_serialize($skills) : serialize(array());
- $interests = !empty($interests) ? maybe_serialize($interests) : serialize(array());
+ if ($uid == $user_id) continue;
+ if (!get_user_meta($uid, '_matchmaking_profile', true)) continue;
$photo = get_wpem_user_profile_photo($uid);
- $organization_logo = get_user_meta( $uid, '_organization_logo', true );
- $organization_logo = maybe_unserialize( $organization_logo );
+
+ // Normalize organization logo
+ $organization_logo = get_user_meta($uid, '_organization_logo', true);
+ $organization_logo = maybe_unserialize($organization_logo);
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
- // Get taxonomy lists
- $profession_terms = get_event_registration_taxonomy_list('event_registration_professions'); // [slug => name]
- $skills_terms = get_event_registration_taxonomy_list('event_registration_skills');
- $interests_terms = get_event_registration_taxonomy_list('event_registration_interests');
- // Profession slug
+ // Profession
$profession_value = get_user_meta($uid, '_profession', true);
- $profession_slug = $profession_value;
+ $profession_slug = $profession_value;
if ($profession_value && !isset($profession_terms[$profession_value])) {
$found_slug = array_search($profession_value, $profession_terms);
if ($found_slug) {
@@ -285,31 +267,30 @@ public function handle_filter_users($request) {
}
}
- // Skills slugs
- $skills_raw = get_user_meta($uid, '_skills', true);
- $skills_arr = is_array($skills_raw) ? $skills_raw : maybe_unserialize($skills_raw);
+ // Skills
+ $skills_arr = (array) maybe_unserialize(get_user_meta($uid, '_skills', true));
$skills_slugs = [];
- foreach ((array)$skills_arr as $skill) {
+ foreach ($skills_arr as $skill) {
if ($skill && !isset($skills_terms[$skill])) {
$found_slug = array_search($skill, $skills_terms);
- $skills_slugs[] = $found_slug ? $found_slug : $skill;
+ $skills_slugs[] = $found_slug ?: $skill;
} else {
$skills_slugs[] = $skill;
}
}
- // Interests slugs
- $interests_raw = get_user_meta($uid, '_interests', true);
- $interests_arr = is_array($interests_raw) ? $interests_raw : maybe_unserialize($interests_raw);
+ // Interests
+ $interests_arr = (array) maybe_unserialize(get_user_meta($uid, '_interests', true));
$interests_slugs = [];
- foreach ((array)$interests_arr as $interest) {
+ foreach ($interests_arr as $interest) {
if ($interest && !isset($interests_terms[$interest])) {
$found_slug = array_search($interest, $interests_terms);
- $interests_slugs[] = $found_slug ? $found_slug : $interest;
+ $interests_slugs[] = $found_slug ?: $interest;
} else {
$interests_slugs[] = $interest;
}
}
+
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
@@ -324,17 +305,17 @@ public function handle_filter_users($request) {
'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => maybe_serialize($skills_slugs),
- 'interests' => maybe_serialize($interests_slugs),
+ 'skills' => maybe_serialize($skills_slugs),
+ 'interests' => maybe_serialize($interests_slugs),
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
'organization_logo' => $organization_logo,
'organization_country' => get_user_meta($uid, '_organization_country', true),
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
- 'organization_website' => get_user_meta($uid, '_organization_website', true),
- 'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
- 'approve_profile_status' => get_user_meta($uid, '_approve_profile_status', true),
+ 'organization_website' => get_user_meta($uid, '_organization_website', true),
+ 'available_for_meeting' => get_user_meta($uid, '_available_for_meeting', true),
+ 'approve_profile_status'=> get_user_meta($uid, '_approve_profile_status', true),
];
}
@@ -353,19 +334,25 @@ public function handle_filter_users($request) {
return false;
}
if (!empty($skills) && is_array($skills)) {
- $user_skills = maybe_unserialize($user['skills']);
- if (!array_intersect($skills, $user_skills)) {
+ if (!array_intersect($skills, $user['skills'])) {
return false;
}
}
if (!empty($interests) && is_array($interests)) {
- $user_interests = maybe_unserialize($user['interests']);
- if (!array_intersect($interests, $user_interests)) {
+ if (!array_intersect($interests, $user['interests'])) {
return false;
}
}
if ($search) {
- $haystack = strtolower(implode(' ', $user));
+ $haystack_parts = [];
+ foreach ($user as $key => $val) {
+ if (is_array($val)) {
+ $haystack_parts = array_merge($haystack_parts, $val);
+ } else {
+ $haystack_parts[] = $val;
+ }
+ }
+ $haystack = strtolower(implode(' ', $haystack_parts));
if (strpos($haystack, strtolower($search)) === false) {
return false;
}
From d310e7de215654849299c528f7987e164a1d12a5 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 20 Aug 2025 18:51:48 +0530
Subject: [PATCH 150/171] #200 Coming empty strings array in filter user api
for skills and interest
---
.../wpem-rest-matchmaking-filter-users.php | 52 ++++++++++++-------
includes/wpem-rest-matchmaking-profile.php | 29 +++++++----
2 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index a44fc62..55f419b 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -267,29 +267,45 @@ public function handle_filter_users($request) {
}
}
- // Skills
- $skills_arr = (array) maybe_unserialize(get_user_meta($uid, '_skills', true));
+ // --- Skills ---
$skills_slugs = [];
- foreach ($skills_arr as $skill) {
- if ($skill && !isset($skills_terms[$skill])) {
- $found_slug = array_search($skill, $skills_terms);
- $skills_slugs[] = $found_slug ?: $skill;
- } else {
- $skills_slugs[] = $skill;
+ $skills_arr = maybe_unserialize(get_user_meta($uid, '_skills', true));
+ if (is_array($skills_arr)) {
+ foreach ($skills_arr as $skill) {
+ $term = get_term_by('slug', $skill, 'event_registration_skills');
+ if (!$term) {
+ $term = get_term_by('name', $skill, 'event_registration_skills');
+ }
+ if (!$term) {
+ $term = get_term_by('id', $skill, 'event_registration_skills');
+ }
+ if ($term) {
+ $skills_slugs[] = $term->slug;
+ }
}
}
+ $skills_slugs = array_filter($skills_slugs); // remove blanks
+ $skills_serialized = serialize($skills_slugs);
- // Interests
- $interests_arr = (array) maybe_unserialize(get_user_meta($uid, '_interests', true));
+ // --- Interests ---
$interests_slugs = [];
- foreach ($interests_arr as $interest) {
- if ($interest && !isset($interests_terms[$interest])) {
- $found_slug = array_search($interest, $interests_terms);
- $interests_slugs[] = $found_slug ?: $interest;
- } else {
- $interests_slugs[] = $interest;
+ $interests_arr = maybe_unserialize(get_user_meta($uid, '_interests', true));
+ if (is_array($interests_arr)) {
+ foreach ($interests_arr as $interest) {
+ $term = get_term_by('slug', $interest, 'event_registration_interests');
+ if (!$term) {
+ $term = get_term_by('name', $interest, 'event_registration_interests');
+ }
+ if (!$term) {
+ $term = get_term_by('id', $interest, 'event_registration_interests');
+ }
+ if ($term) {
+ $interests_slugs[] = $term->slug;
+ }
}
}
+ $interests_slugs = array_filter($interests_slugs);
+ $interests_serialized = serialize($interests_slugs);
$users_data[] = [
'user_id' => $uid,
@@ -305,8 +321,8 @@ public function handle_filter_users($request) {
'country' => get_user_meta($uid, '_country', true),
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => maybe_serialize($skills_slugs),
- 'interests' => maybe_serialize($interests_slugs),
+ 'skills' => $skills_serialized,
+ 'interests' => $interests_serialized,
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
'organization_logo' => $organization_logo,
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 2d0f717..faf0f24 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -59,7 +59,7 @@ public function register_routes() {
);
}
- public function get_attendee_profile($request) {
+ public function get_attendee_profile($request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response(array(
'code' => 403,
@@ -117,7 +117,6 @@ public function get_attendee_profile($request) {
$profession_slug = $found_slug;
}
}
- // Convert skills (names or IDs) to slugs
$skills_slugs = array();
if (!empty($user_meta['_skills'][0])) {
$skills = maybe_unserialize($user_meta['_skills'][0]);
@@ -133,8 +132,10 @@ public function get_attendee_profile($request) {
}
}
}
+ $skills_slugs = array_filter($skills_slugs); // remove blanks
+ $skills_serialized = serialize($skills_slugs);
- // Convert interests (names or IDs) to slugs
+ // Convert interests to slugs and serialize
$interests_slugs = array();
if (!empty($user_meta['_interests'][0])) {
$interests = maybe_unserialize($user_meta['_interests'][0]);
@@ -150,6 +151,8 @@ public function get_attendee_profile($request) {
}
}
}
+ $interests_slugs = array_filter($interests_slugs);
+ $interests_serialized = serialize($interests_slugs);
// Format the profile data
$profile = array(
@@ -166,8 +169,10 @@ public function get_attendee_profile($request) {
'country' => $country_code,
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => maybe_serialize($skills_slugs),
- 'interests' => maybe_serialize($interests_slugs),
+ //'skills' => maybe_serialize($skills_slugs),
+ //'interests' => maybe_serialize($interests_slugs),
+ 'skills' => $skills_serialized,
+ 'interests' => $interests_serialized,
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => $organization_logo,
@@ -225,7 +230,6 @@ public function get_attendee_profile($request) {
$profession_slug = $found_slug;
}
}
- // Convert skills (names or IDs) to slugs
$skills_slugs = array();
if (!empty($user_meta['_skills'][0])) {
$skills = maybe_unserialize($user_meta['_skills'][0]);
@@ -241,7 +245,10 @@ public function get_attendee_profile($request) {
}
}
}
- // Convert interests (names or IDs) to slugs
+ $skills_slugs = array_filter($skills_slugs);
+ $skills_serialized = serialize($skills_slugs);
+
+ // Convert interests
$interests_slugs = array();
if (!empty($user_meta['_interests'][0])) {
$interests = maybe_unserialize($user_meta['_interests'][0]);
@@ -257,6 +264,8 @@ public function get_attendee_profile($request) {
}
}
}
+ $interests_slugs = array_filter($interests_slugs);
+ $interests_serialized = serialize($interests_slugs);
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
@@ -265,14 +274,14 @@ public function get_attendee_profile($request) {
'email' => $user->user_email,
'matchmaking_profile' => isset($user_meta['_matchmaking_profile'][0]) ? (int)$user_meta['_matchmaking_profile'][0] : 0,
'profile_photo' => $photo,
- 'profession' => $profession_slug,
+ 'profession' => $profession_slug ,
'experience' => isset($user_meta['_experience'][0]) ? (float)$user_meta['_experience'][0] : 0,
'company_name' => isset($user_meta['_company_name'][0]) ? sanitize_text_field($user_meta['_company_name'][0]) : '',
'country' => $country_code,
'city' => isset($user_meta['_city'][0]) ? sanitize_text_field($user_meta['_city'][0]) : '',
'about' => isset($user_meta['_about'][0]) ? sanitize_textarea_field($user_meta['_about'][0]) : '',
- 'skills' => maybe_serialize($skills_slugs),
- 'interests' => maybe_serialize($interests_slugs),
+ 'skills' => $skills_serialized,
+ 'interests' => $interests_serialized,
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => $organization_logo,
From c60d6af3fa8f3538d6cf1e23abe0c24a252b7ee1 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 20 Aug 2025 20:48:00 +0530
Subject: [PATCH 151/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-authentication.php | 80 ++++++++++++++++++++++-----
1 file changed, 66 insertions(+), 14 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index 0ace47e..c1ea8d3 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -730,22 +730,74 @@ public function perform_user_authentication($request) {
$meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
$photo = get_wpem_user_profile_photo($user_id);
+
+ // --- Skills ---
+ $skills_slugs = [];
+ $skills_arr = maybe_unserialize(isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : []);
+ if (is_array($skills_arr)) {
+ foreach ($skills_arr as $skill) {
+ $term = get_term_by('slug', $skill, 'event_registration_skills');
+ if (!$term) {
+ $term = get_term_by('name', $skill, 'event_registration_skills');
+ }
+ if (!$term) {
+ $term = get_term_by('id', $skill, 'event_registration_skills');
+ }
+ if ($term) {
+ $skills_slugs[] = $term->slug;
+ }
+ }
+ }
+ $skills_slugs = array_filter($skills_slugs);
+ $skills_serialized = serialize($skills_slugs);
+
+ // --- Interests ---
+ $interests_slugs = [];
+ $interests_arr = maybe_unserialize(isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : []);
+ if (is_array($interests_arr)) {
+ foreach ($interests_arr as $interest) {
+ $term = get_term_by('slug', $interest, 'event_registration_interests');
+ if (!$term) {
+ $term = get_term_by('name', $interest, 'event_registration_interests');
+ }
+ if (!$term) {
+ $term = get_term_by('id', $interest, 'event_registration_interests');
+ }
+ if ($term) {
+ $interests_slugs[] = $term->slug;
+ }
+ }
+ }
+
+ $interests_slugs = array_filter($interests_slugs);
+ $interests_serialized = serialize($interests_slugs);
+ $profession = get_user_meta($user_id, '_profession', true) ?: '';
+ if (!empty($profession)) {
+ $term = get_term_by('name', $profession, 'event_registration_professions');
+ if (!$term) {
+ $term = get_term_by('slug', $profession, 'event_registration_professions');
+ }
+ $profession_slug = $term ? $term->slug : $profession;
+ } else {
+ $profession_slug = '';
+ }
+
// Get matchmaking data from user meta instead of custom table
$matchmaking_details = array(
- 'attendeeId' => $user_id,
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'email' => $user->user_email,
- 'display_name' => $user->display_name,
- 'profile_photo' => $photo,
- 'profession' => get_user_meta($user_id, '_profession', true) ?: '',
- 'experience' => get_user_meta($user_id, '_experience', true) ?: '',
- 'company_name' => get_user_meta($user_id, '_company_name', true) ?: '',
- 'country' => get_user_meta($user_id, '_country', true) ?: '',
- 'city' => get_user_meta($user_id, '_city', true) ?: '',
- 'about' => get_user_meta($user_id, '_about', true) ?: '',
- 'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
- 'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
+ 'attendeeId' => $user_id,
+ 'first_name' => $first_name,
+ 'last_name' => $last_name,
+ 'email' => $user->user_email,
+ 'display_name' => $user->display_name,
+ 'profile_photo' => $photo,
+ 'profession' => $profession_slug,
+ 'experience' => get_user_meta($user_id, '_experience', true) ?: '',
+ 'company_name' => get_user_meta($user_id, '_company_name', true) ?: '',
+ 'country' => get_user_meta($user_id, '_country', true) ?: '',
+ 'city' => get_user_meta($user_id, '_city', true) ?: '',
+ 'about' => get_user_meta($user_id, '_about', true) ?: '',
+ 'skills' => isset($user_meta['_skills'][0]) ? $user_meta['_skills'][0] : array(),
+ 'interests' => isset($user_meta['_interests'][0]) ? $user_meta['_interests'][0] : array(),
'organization_name' => get_user_meta($user_id, '_organization_name', true) ?: '',
'organization_logo' => $organization_logo,
'organization_city' => get_user_meta($user_id, '_organization_city', true) ?: '',
From e4ebab8a284662a2016ce045a908457ae13d6caf Mon Sep 17 00:00:00 2001
From: Roshani
Date: Wed, 20 Aug 2025 21:17:16 +0530
Subject: [PATCH 152/171] #222 Update Profile Not working
---
includes/wpem-rest-matchmaking-profile.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index faf0f24..839fa08 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -246,7 +246,7 @@ public function get_attendee_profile($request) {
}
}
$skills_slugs = array_filter($skills_slugs);
- $skills_serialized = serialize($skills_slugs);
+ $skills_serialized = maybe_serialize($skills_slugs);
// Convert interests
$interests_slugs = array();
@@ -265,7 +265,7 @@ public function get_attendee_profile($request) {
}
}
$interests_slugs = array_filter($interests_slugs);
- $interests_serialized = serialize($interests_slugs);
+ $interests_serialized = maybe_serialize($interests_slugs);
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
From 978b09af79e3696a4a6b7963b8e347669c5bd3f7 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 10:11:14 +0530
Subject: [PATCH 153/171] #192 Please Check Payload format and response of this
Listed apis
---
includes/wpem-rest-matchmaking-profile.php | 23 ++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 839fa08..a23f0ad 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -101,6 +101,16 @@ public function get_attendee_profile($request) {
$country_code = array_search($country_value, $countries);
}
}
+ // Get organization country value from user meta
+ $org_country_value = isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '';
+ $org_country_code = '';
+ if ($org_country_value) {
+ if (isset($countries[$org_country_value])) {
+ $org_country_code = $org_country_value;
+ } else {
+ $org_country_code = array_search($org_country_value, $countries);
+ }
+ }
$meta = get_user_meta($attendee_id, '_available_for_meeting', true);
$meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
// Get all profession terms [slug => name]
@@ -176,7 +186,7 @@ public function get_attendee_profile($request) {
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => $organization_logo,
- 'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
+ 'organization_country' => $org_country_code,
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
'organization_website' => isset($user_meta['_organization_website'][0]) ? sanitize_text_field($user_meta['_organization_website'][0]) : '',
@@ -218,6 +228,15 @@ public function get_attendee_profile($request) {
$country_code = array_search($country_value, $countries);
}
}
+ $org_country_value = isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '';
+ $org_country_code = '';
+ if ($org_country_value) {
+ if (isset($countries[$org_country_value])) {
+ $org_country_code = $org_country_value;
+ } else {
+ $org_country_code = array_search($org_country_value, $countries);
+ }
+ }
$meta = get_user_meta($user->ID, '_available_for_meeting', true);
$meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
// Profession slug logic
@@ -285,7 +304,7 @@ public function get_attendee_profile($request) {
'message_notification' => isset($user_meta['_message_notification'][0]) ? (int)$user_meta['_message_notification'][0] : 0,
'organization_name' => isset($user_meta['_organization_name'][0]) ? sanitize_text_field($user_meta['_organization_name'][0]) : '',
'organization_logo' => $organization_logo,
- 'organization_country' => isset($user_meta['_organization_country'][0]) ? sanitize_text_field($user_meta['_organization_country'][0]) : '',
+ 'organization_country' => $org_country_code,
'organization_city' => isset($user_meta['_organization_city'][0]) ? sanitize_text_field($user_meta['_organization_city'][0]) : '',
'organization_description' => isset($user_meta['_organization_description'][0]) ? sanitize_textarea_field($user_meta['_organization_description'][0]) : '',
'organization_website' => isset($user_meta['_organization_website'][0]) ? sanitize_text_field($user_meta['_organization_website'][0]) : '',
From a9a27e162020a9c4aa5c912b394230d44254a3e4 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 10:17:39 +0530
Subject: [PATCH 154/171] #192 Please Check Payload format and response of this
Listed apis
---
.../wpem-rest-matchmaking-filter-users.php | 30 +++++++++++++++----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 55f419b..4defa8f 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -306,7 +306,27 @@ public function handle_filter_users($request) {
}
$interests_slugs = array_filter($interests_slugs);
$interests_serialized = serialize($interests_slugs);
-
+
+ $countries = wpem_get_all_countries();
+ $country_value = get_user_meta($uid, '_country', true);
+ $country_code = '';
+ if ($country_value) {
+ if (isset($countries[$country_value])) {
+ $country_code = $country_value;
+ } else {
+ $country_code = array_search($country_value, $countries);
+ }
+ }
+ // Get organization country value from user meta
+ $org_country_value = get_user_meta($uid, '_organization_country', true);
+ $org_country_code = '';
+ if ($org_country_value) {
+ if (isset($countries[$org_country_value])) {
+ $org_country_code = $org_country_value;
+ } else {
+ $org_country_code = array_search($org_country_value, $countries);
+ }
+ }
$users_data[] = [
'user_id' => $uid,
'display_name' => get_the_author_meta('display_name', $uid),
@@ -318,15 +338,15 @@ public function handle_filter_users($request) {
'profession' => $profession_slug,
'experience' => get_user_meta($uid, '_experience', true),
'company_name' => get_user_meta($uid, '_company_name', true),
- 'country' => get_user_meta($uid, '_country', true),
+ 'country' => $country_code,
'city' => get_user_meta($uid, '_city', true),
'about' => get_user_meta($uid, '_about', true),
- 'skills' => $skills_serialized,
- 'interests' => $interests_serialized,
+ 'skills' => $skills_serialized,
+ 'interests' => $interests_serialized,
'message_notification' => get_user_meta($uid, '_message_notification', true),
'organization_name' => get_user_meta($uid, '_organization_name', true),
'organization_logo' => $organization_logo,
- 'organization_country' => get_user_meta($uid, '_organization_country', true),
+ 'organization_country' => $org_country_code,
'organization_city' => get_user_meta($uid, '_organization_city', true),
'organization_description'=> get_user_meta($uid, '_organization_description', true),
'organization_website' => get_user_meta($uid, '_organization_website', true),
From d3f03597c3df3b4e1a4153f69287681a1d5fb949 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 11:18:50 +0530
Subject: [PATCH 155/171] #224 Add deffault image in apis
---
includes/wpem-rest-authentication.php | 3 +-
.../wpem-rest-matchmaking-create-meetings.php | 30 ++++++++++++++-----
.../wpem-rest-matchmaking-filter-users.php | 4 +--
includes/wpem-rest-matchmaking-profile.php | 7 +++--
4 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/includes/wpem-rest-authentication.php b/includes/wpem-rest-authentication.php
index c1ea8d3..c062aa5 100644
--- a/includes/wpem-rest-authentication.php
+++ b/includes/wpem-rest-authentication.php
@@ -726,10 +726,11 @@ public function perform_user_authentication($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo); // get first value in the array
}
+ $organization_logo = $organization_logo ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/organisation-icon.jpg';
$meta = get_user_meta($user_id, '_available_for_meeting', true);
$meeting_available = ($meta !== '' && $meta !== null) ? ((int)$meta === 0 ? 0 : 1) : 1;
- $photo = get_wpem_user_profile_photo($user_id);
+ $photo = get_wpem_user_profile_photo($user_id) ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
// --- Skills ---
$skills_slugs = [];
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 1df875a..f42ecd7 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -404,16 +404,23 @@ public function get_user_meetings(WP_REST_Request $request) {
}
// Get profile data from user meta (assuming these are stored as meta)
- $profile_photo = get_wpem_user_profile_photo($pid);
- $profession = get_user_meta($pid, '_profession', true); // Note: Typo in 'profession'?
+ $profile_photo = get_wpem_user_profile_photo($pid) ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
$company_name = get_user_meta($pid, '_company_name', true);
-
+ $profession_terms = get_event_registration_taxonomy_list('event_registration_professions');
+ $profession_value = get_user_meta($pid, '_profession', true);
+ $profession_slug = $profession_value;
+ if ($profession_value && !isset($profession_terms[$profession_value])) {
+ $found_slug = array_search($profession_value, $profession_terms);
+ if ($found_slug) {
+ $profession_slug = $found_slug;
+ }
+ }
$participants_info[] = [
'id' => (int)$pid,
'status' => (int)$status,
'name' => $display_name,
- 'profile_photo' => !empty($profile_photo) ? esc_url($profile_photo) : '',
- 'profession' => !empty($profession) ? esc_html($profession) : '',
+ 'profile_photo' => $profile_photo,
+ 'profession' => $profession_slug,
'company_name' => !empty($company_name) ? esc_html($company_name) : '',
];
}
@@ -428,15 +435,22 @@ public function get_user_meetings(WP_REST_Request $request) {
}
// Get host profile data from user meta
- $host_profile_photo = get_wpem_user_profile_photo($host_id);
- $host_profession = get_user_meta($host_id, '_profession', true);
+ $host_profile_photo = get_wpem_user_profile_photo($host_id) ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
+ $host_profession_value = get_user_meta($host_id, '_profession', true);
+ $host_profession_slug = $host_profession_value;
+ if ($host_profession_value && !isset($profession_terms[$host_profession_value])) {
+ $found_slug = array_search($host_profession_value, $profession_terms);
+ if ($found_slug) {
+ $host_profession_slug = $found_slug;
+ }
+ }
$host_company_name = get_user_meta($host_id, '_company_name', true);
$host_info = [
'id' => $host_id,
'name' => $host_display_name,
'profile_photo' => !empty($host_profile_photo) ? esc_url($host_profile_photo) : '',
- 'profession' => !empty($host_profession) ? esc_html($host_profession) : '',
+ 'profession' => $host_profession_slug,
'company_name' => !empty($host_company_name) ? esc_html($host_company_name) : '',
];
diff --git a/includes/wpem-rest-matchmaking-filter-users.php b/includes/wpem-rest-matchmaking-filter-users.php
index 4defa8f..c99160d 100644
--- a/includes/wpem-rest-matchmaking-filter-users.php
+++ b/includes/wpem-rest-matchmaking-filter-users.php
@@ -248,7 +248,7 @@ public function handle_filter_users($request) {
if ($uid == $user_id) continue;
if (!get_user_meta($uid, '_matchmaking_profile', true)) continue;
- $photo = get_wpem_user_profile_photo($uid);
+ $photo = get_wpem_user_profile_photo($uid) ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
// Normalize organization logo
$organization_logo = get_user_meta($uid, '_organization_logo', true);
@@ -256,7 +256,7 @@ public function handle_filter_users($request) {
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
-
+ $organization_logo = $organization_logo ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/organisation-icon.jpg';
// Profession
$profession_value = get_user_meta($uid, '_profession', true);
$profession_slug = $profession_value;
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index a23f0ad..162854c 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -85,13 +85,13 @@ public function get_attendee_profile($request) {
// Get all user meta
$user_meta = get_user_meta($attendee_id);
- $photo = get_wpem_user_profile_photo($attendee_id);
+ $photo = get_wpem_user_profile_photo($attendee_id) ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
$organization_logo = get_user_meta( $attendee_id, '_organization_logo', true );
$organization_logo = maybe_unserialize( $organization_logo );
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo); // get first value in the array
}
-
+ $organization_logo = $organization_logo ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/organisation-icon.jpg';
$country_value = isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '';
$country_code = '';
if ($country_value) {
@@ -213,12 +213,13 @@ public function get_attendee_profile($request) {
$profiles = array();
foreach ($users as $user) {
$user_meta = get_user_meta($user->ID);
- $photo = get_wpem_user_profile_photo($user->ID);
+ $photo = get_wpem_user_profile_photo($user->ID) ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/user-profile-photo.png';
$organization_logo = get_user_meta( $user->ID, '_organization_logo', true );
$organization_logo = maybe_unserialize( $organization_logo );
if (is_array($organization_logo)) {
$organization_logo = reset($organization_logo);
}
+ $organization_logo = $organization_logo ?: EVENT_MANAGER_REGISTRATIONS_PLUGIN_URL . '/assets/images/organisation-icon.jpg';
$country_value = isset($user_meta['_country'][0]) ? sanitize_text_field($user_meta['_country'][0]) : '';
$country_code = '';
if ($country_value) {
From a2490793d4c84f3c566a1b9af8f45b1ef1dd26d4 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 12:33:00 +0530
Subject: [PATCH 156/171] #215 Not able to create meeting
---
includes/wpem-rest-matchmaking-create-meetings.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index f42ecd7..c54c249 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -317,7 +317,7 @@ public function create_meeting(WP_REST_Request $request) {
}
// Update booked slot (same as before)
- $slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+ /*$slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
if (!is_array($slot_data)) {
$slot_data = [];
}
@@ -328,7 +328,7 @@ public function create_meeting(WP_REST_Request $request) {
$slot_data[$event_id][$meeting_date] = [];
}
$slot_data[$event_id][$meeting_date][$slot] = 2;
- update_user_meta($user_id, '_meeting_availability_slot', $slot_data);
+ update_user_meta($user_id, '_meeting_availability_slot', $slot_data);*/
return new WP_REST_Response([
'code' => 200,
From 9b1068a881e88635dec58dcb9d01910ff41fbeb7 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 12:44:25 +0530
Subject: [PATCH 157/171] #222 Update Profile Not working
---
includes/wpem-rest-matchmaking-profile.php | 32 +++++++++++++++++-----
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 162854c..17b0b32 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -360,19 +360,37 @@ public function update_attendee_profile($request) {
foreach ($meta_fields as $field) {
if ($request->get_param($field) !== null) {
$value = $request->get_param($field);
- // If it's an array, filter out blanks
- if (is_array($value)) {
+
+ // For skills and interests, always save as serialized array
+ if (in_array($field, ['skills', 'interests'])) {
+ // Ensure value is always an array
+ if (!is_array($value)) {
+ $value = [$value];
+ }
$value = array_filter($value, function($v) {
return $v !== null && $v !== '';
});
$value = array_values($value); // reindex after filtering
- }
- // Only update if not completely empty
- if (!empty($value)) {
- update_user_meta($user_id, '_' . $field, $value);
+ // Save as serialized array (produces a:2:{i:0;s:...;i:1;s:...;} format)
+ if (!empty($value)) {
+ update_user_meta($user_id, '_' . $field, $value);
+ } else {
+ update_user_meta($user_id, '_' . $field, '');
+ }
} else {
- update_user_meta($user_id, '_' . $field, ''); // cleanup if blank
+ // For other fields
+ if (is_array($value)) {
+ $value = array_filter($value, function($v) {
+ return $v !== null && $v !== '';
+ });
+ $value = array_values($value); // reindex after filtering
+ }
+ if (!empty($value)) {
+ update_user_meta($user_id, '_' . $field, $value);
+ } else {
+ update_user_meta($user_id, '_' . $field, ''); // cleanup if blank
+ }
}
}
}
From 63f6ac08eb3b444cb121fdb1cc6ecec5f1d49237 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 13:16:49 +0530
Subject: [PATCH 158/171] #215 Not able to create meeting
---
includes/wpem-rest-matchmaking-create-meetings.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index c54c249..63558ef 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -526,7 +526,7 @@ public function cancel_meeting(WP_REST_Request $request) {
$participant_ids = array_unique($participant_ids);
// === Availability reset ===
- $event_id = (int)$meeting['event_id'];
+ /* $event_id = (int)$meeting['event_id'];
$meeting_date = $meeting['meeting_date'];
$start_time = date('H:i', strtotime($meeting['meeting_start_time']));
@@ -543,7 +543,7 @@ public function cancel_meeting(WP_REST_Request $request) {
$slot_data[$event_id][$meeting_date][$start_time] = 1;
update_user_meta($pid, '_meeting_availability_slot', $slot_data);
}
- }
+ }*/
// Notify participants
foreach ($participant_ids as $pid) {
From 6b13dbb9c0dac408cc23c27a1d8837725d129047 Mon Sep 17 00:00:00 2001
From: Rita
Date: Thu, 21 Aug 2025 13:23:47 +0530
Subject: [PATCH 159/171] Warning:
include(includes/wpem-rest-matchmaking-users-settings.php): Failed to open
stream: No such file or directory #225
---
includes/wpem-rest-crud-controller.php | 35 +++++++++++-----------
includes/wpem-rest-matchmaking-profile.php | 4 +--
wpem-rest-api.php | 2 +-
3 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/includes/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
index fd3ca82..e5a1067 100644
--- a/includes/wpem-rest-crud-controller.php
+++ b/includes/wpem-rest-crud-controller.php
@@ -430,12 +430,10 @@ protected function get_objects( $query_args ) {
public function get_items( $request ) {
global $wpdb;
-
$auth_check = $this->wpem_check_authorized_user();
if ($auth_check) {
return self::prepare_error_for_response(405);
} else {
-
$settings_row = $wpdb->get_row("SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys LIMIT 1", ARRAY_A);
$event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
@@ -726,19 +724,23 @@ public function wpem_check_authorized_user() {
}
$user = get_userdata($user_data['id']);
- if($user){
- $user_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = $user->ID "));
- if($user_info){
- $date_expires = date('Y-m-d', strtotime($user_info->date_expires));
- if( $user_info->permissions == 'write'){
- return self::prepare_error_for_response(203);
- } else if( $date_expires < date('Y-m-d') ){
- return self::prepare_error_for_response(503);
+ if($user){
+ if (!wp_check_password($user_data['password'], $user->user_pass, $user->ID)) {
+ return self::prepare_error_for_response(405);
+ } else {
+ $user_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = $user->ID "));
+ if($user_info){
+ $date_expires = date('Y-m-d', strtotime($user_info->date_expires));
+ if( $user_info->permissions == 'write'){
+ return self::prepare_error_for_response(203);
+ } else if( $date_expires < date('Y-m-d') ){
+ return self::prepare_error_for_response(503);
+ } else {
+ return false;
+ }
} else {
- return false;
+ return self::prepare_error_for_response(405);
}
- } else {
- return self::prepare_error_for_response(405);
}
} else {
return self::prepare_error_for_response(405);
@@ -757,7 +759,7 @@ public static function wpem_validate_jwt_token($token) {
$expected_signature = wpem_base64url_encode(
hash_hmac('sha256', "$header.$payload", JWT_SECRET_KEY, true)
- );
+ );
if (!hash_equals($expected_signature, $signature)) {
return false;
@@ -771,7 +773,7 @@ public static function wpem_validate_jwt_token($token) {
// Clean up keys (defensive)
$user = array_change_key_case(array_map('trim', $payload_data['user']));
-
+
return $user;
}
@@ -805,5 +807,4 @@ public static function prepare_error_for_response( $code, $data = array()) {
return null; // Or handle the case where code 400 is not found
}
}
-
-}
+}
\ No newline at end of file
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 162854c..c4932e1 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -1,7 +1,7 @@
Date: Thu, 21 Aug 2025 13:57:26 +0530
Subject: [PATCH 160/171] #215 Not able to create meeting
---
includes/wpem-rest-matchmaking-create-meetings.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index 63558ef..c54c249 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -526,7 +526,7 @@ public function cancel_meeting(WP_REST_Request $request) {
$participant_ids = array_unique($participant_ids);
// === Availability reset ===
- /* $event_id = (int)$meeting['event_id'];
+ $event_id = (int)$meeting['event_id'];
$meeting_date = $meeting['meeting_date'];
$start_time = date('H:i', strtotime($meeting['meeting_start_time']));
@@ -543,7 +543,7 @@ public function cancel_meeting(WP_REST_Request $request) {
$slot_data[$event_id][$meeting_date][$start_time] = 1;
update_user_meta($pid, '_meeting_availability_slot', $slot_data);
}
- }*/
+ }
// Notify participants
foreach ($participant_ids as $pid) {
From e62315cb143cb1b98f72d4f4d355a1036d6a4fd3 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 14:59:29 +0530
Subject: [PATCH 161/171] #222
---
includes/wpem-rest-matchmaking-profile.php | 118 +++++++++++----------
1 file changed, 61 insertions(+), 57 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-profile.php b/includes/wpem-rest-matchmaking-profile.php
index 46f0da5..6931a01 100644
--- a/includes/wpem-rest-matchmaking-profile.php
+++ b/includes/wpem-rest-matchmaking-profile.php
@@ -59,7 +59,7 @@ public function register_routes() {
);
}
- public function get_attendee_profile($request) {
+ public function get_attendee_profile($request) {
if (!get_option('enable_matchmaking', false)) {
return new WP_REST_Response(array(
'code' => 403,
@@ -127,37 +127,39 @@ public function get_attendee_profile($request) {
$profession_slug = $found_slug;
}
}
- $skills_slugs = array();
- if (!empty($user_meta['_skills'][0])) {
- $skills = maybe_unserialize($user_meta['_skills'][0]);
- if (is_array($skills)) {
- foreach ($skills as $skill) {
+ $skills_slugs = [];
+ $skills_arr = maybe_unserialize($user_meta['_skills'][0]);
+ if (is_array($skills_arr)) {
+ foreach ($skills_arr as $skill) {
+ $term = get_term_by('slug', $skill, 'event_registration_skills');
+ if (!$term) {
$term = get_term_by('name', $skill, 'event_registration_skills');
- if (!$term) {
- $term = get_term_by('id', $skill, 'event_registration_skills');
- }
- if ($term) {
- $skills_slugs[] = $term->slug;
- }
+ }
+ if (!$term) {
+ $term = get_term_by('id', $skill, 'event_registration_skills');
+ }
+ if ($term) {
+ $skills_slugs[] = $term->slug;
}
}
}
$skills_slugs = array_filter($skills_slugs); // remove blanks
$skills_serialized = serialize($skills_slugs);
- // Convert interests to slugs and serialize
- $interests_slugs = array();
- if (!empty($user_meta['_interests'][0])) {
- $interests = maybe_unserialize($user_meta['_interests'][0]);
- if (is_array($interests)) {
- foreach ($interests as $interest) {
+ // --- Interests ---
+ $interests_slugs = [];
+ $interests_arr = maybe_unserialize($user_meta['_interests'][0]);
+ if (is_array($interests_arr)) {
+ foreach ($interests_arr as $interest) {
+ $term = get_term_by('slug', $interest, 'event_registration_interests');
+ if (!$term) {
$term = get_term_by('name', $interest, 'event_registration_interests');
- if (!$term) {
- $term = get_term_by('id', $interest, 'event_registration_interests');
- }
- if ($term) {
- $interests_slugs[] = $term->slug;
- }
+ }
+ if (!$term) {
+ $term = get_term_by('id', $interest, 'event_registration_interests');
+ }
+ if ($term) {
+ $interests_slugs[] = $term->slug;
}
}
}
@@ -250,42 +252,45 @@ public function get_attendee_profile($request) {
$profession_slug = $found_slug;
}
}
- $skills_slugs = array();
- if (!empty($user_meta['_skills'][0])) {
- $skills = maybe_unserialize($user_meta['_skills'][0]);
- if (is_array($skills)) {
- foreach ($skills as $skill) {
- $term = get_term_by('name', $skill, 'event_registration_skills');
- if (!$term) {
- $term = get_term_by('id', $skill, 'event_registration_skills');
- }
- if ($term) {
- $skills_slugs[] = $term->slug;
- }
- }
+ $skills_slugs = [];
+ $skills_arr = maybe_unserialize($user_meta['_skills'][0]);
+ if (is_array($skills_arr)) {
+ foreach ($skills_arr as $skill) {
+ $term = get_term_by('slug', $skill, 'event_registration_skills');
+ if (!$term) {
+ $term = get_term_by('name', $skill, 'event_registration_skills');
+ }
+ if (!$term) {
+ $term = get_term_by('id', $skill, 'event_registration_skills');
+ }
+ if ($term) {
+ $skills_slugs[] = $term->slug;
}
}
- $skills_slugs = array_filter($skills_slugs);
- $skills_serialized = maybe_serialize($skills_slugs);
-
- // Convert interests
- $interests_slugs = array();
- if (!empty($user_meta['_interests'][0])) {
- $interests = maybe_unserialize($user_meta['_interests'][0]);
- if (is_array($interests)) {
- foreach ($interests as $interest) {
- $term = get_term_by('name', $interest, 'event_registration_interests');
- if (!$term) {
- $term = get_term_by('id', $interest, 'event_registration_interests');
- }
- if ($term) {
- $interests_slugs[] = $term->slug;
- }
- }
+ }
+ $skills_slugs = array_filter($skills_slugs); // remove blanks
+ $skills_serialized = serialize($skills_slugs);
+
+ // --- Interests ---
+ $interests_slugs = [];
+ $interests_arr = maybe_unserialize($user_meta['_interests'][0]);
+ if (is_array($interests_arr)) {
+ foreach ($interests_arr as $interest) {
+ $term = get_term_by('slug', $interest, 'event_registration_interests');
+ if (!$term) {
+ $term = get_term_by('name', $interest, 'event_registration_interests');
+ }
+ if (!$term) {
+ $term = get_term_by('id', $interest, 'event_registration_interests');
+ }
+ if ($term) {
+ $interests_slugs[] = $term->slug;
}
}
- $interests_slugs = array_filter($interests_slugs);
- $interests_serialized = maybe_serialize($interests_slugs);
+ }
+ $interests_slugs = array_filter($interests_slugs);
+ $interests_serialized = serialize($interests_slugs);
+
$profiles[] = array(
'user_id' => $user->ID,
'display_name' => $user->display_name,
@@ -323,7 +328,6 @@ public function get_attendee_profile($request) {
), 200);
}
}
-
/**
* Update profile including handling file upload from device for profile_photo
*/
From b041f46ca9b9ad68150f1a8c83095f3767b258ce Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 15:18:00 +0530
Subject: [PATCH 162/171] #215 Not able to create meeting
---
includes/wpem-rest-matchmaking-create-meetings.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-matchmaking-create-meetings.php b/includes/wpem-rest-matchmaking-create-meetings.php
index c54c249..1a2de83 100644
--- a/includes/wpem-rest-matchmaking-create-meetings.php
+++ b/includes/wpem-rest-matchmaking-create-meetings.php
@@ -674,7 +674,7 @@ public function update_meeting_status(WP_REST_Request $request) {
}
// Update availability slot for this user
- $slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
+ /* $slot_data = maybe_unserialize(get_user_meta($user_id, '_meeting_availability_slot', true));
if (!is_array($slot_data)) {
$slot_data = [];
}
@@ -688,7 +688,7 @@ public function update_meeting_status(WP_REST_Request $request) {
$slot_data[$event_id][$meeting_date][date('H:i', strtotime($meeting->meeting_start_time))] = ($new_status === 1) ? 2 : 1;
- update_user_meta($user_id, '_meeting_availability_slot', $slot_data);
+ update_user_meta($user_id, '_meeting_availability_slot', $slot_data);*/
return new WP_REST_Response([
'code' => 200,
From 5b34f3dee773c07a8ad3218a739da9fe481e4019 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 16:30:36 +0530
Subject: [PATCH 163/171] #223 Code issue
---
includes/wpem-rest-crud-controller.php | 4 +-
includes/wpem-rest-events-controller.php | 55 ++++++++++++++++++++++++
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/includes/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
index e5a1067..71d95fa 100644
--- a/includes/wpem-rest-crud-controller.php
+++ b/includes/wpem-rest-crud-controller.php
@@ -434,10 +434,10 @@ public function get_items( $request ) {
if ($auth_check) {
return self::prepare_error_for_response(405);
} else {
- $settings_row = $wpdb->get_row("SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys LIMIT 1", ARRAY_A);
+ /*$settings_row = $wpdb->get_row("SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys LIMIT 1", ARRAY_A);
$event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
- $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];
+ $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];*/
$query_args = $this->prepare_objects_query($request);
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index 63b47c5..8814ea3 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -898,6 +898,61 @@ public function get_event_texonomy( $texonomy = '' ) {
}
return $data;
}
+ public function get_items( $request ) {
+ global $wpdb;
+
+ $user_id = intval( $request['user_id'] );
+ $auth_check = $this->wpem_check_authorized_user( $user_id );
+ if ($auth_check) {
+ return parent::get_items($request);
+ } else {
+ $query_args = $this->prepare_objects_query($request);
+
+ $settings_row = $wpdb->get_row(
+ $wpdb->prepare(
+ "SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %d",
+ $user_id
+ ),
+ ARRAY_A
+ );
+
+ $event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
+ $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];
+
+ if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
+ $query_args['post__in'] = array_map('intval', $selected_events);
+ $query_args['orderby'] = 'post__in';
+ unset($query_args['author']);
+ }
+
+ $query_results = parent::get_objects($query_args);
+
+ $objects = array();
+ foreach ($query_results['objects'] as $object) {
+ $object_id = isset($object->ID) ? $object->ID : $object->get_id();
+
+ if (!wpem_rest_api_check_post_permissions($this->post_type, 'read', $object_id)) {
+ continue;
+ }
+
+ $data = $this->prepare_object_for_response($object, $request);
+ $objects[] = $this->prepare_response_for_collection($data);
+ }
+
+ $page = isset($query_args['paged']) ? (int) $query_args['paged'] : 1;
+ $total_pages = ceil($query_results['total'] / $query_args['posts_per_page']);
+
+ $response_data = self::prepare_error_for_response(200);
+ $response_data['data'] = array(
+ 'total_post_count' => isset($query_results['total']) ? $query_results['total'] : null,
+ 'current_page' => $page,
+ 'last_page' => max(1, $total_pages),
+ 'total_pages' => $total_pages,
+ $this->rest_base => $objects,
+ );
+ return wp_send_json($response_data);
+ }
+ }
}
new WPEM_REST_Events_Controller();
\ No newline at end of file
From 2947b73ed3422064fb1155de38d1c4ccd6494dfb Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 18:16:53 +0530
Subject: [PATCH 164/171] #223
---
includes/wpem-rest-crud-controller.php | 4 ++--
includes/wpem-rest-events-controller.php | 21 ++++++++++++++++++++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/includes/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
index 71d95fa..e721667 100644
--- a/includes/wpem-rest-crud-controller.php
+++ b/includes/wpem-rest-crud-controller.php
@@ -441,11 +441,11 @@ public function get_items( $request ) {
$query_args = $this->prepare_objects_query($request);
- if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
+ /*if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
$query_args['post__in'] = array_map('intval', $selected_events);
$query_args['orderby'] = 'post__in';
unset($query_args['author']);
- }
+ }*/
$query_results = $this->get_objects($query_args);
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index 8814ea3..e5dcc5f 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -239,8 +239,27 @@ protected function prepare_objects_query( $request ) {
$args['author'] = wpem_rest_get_current_user_id();
$args['post_type'] = $this->post_type;
+ // --- Event selection logic ---
+ // Get current user ID
+ $current_user_id = wpem_rest_get_current_user_id();
+ if ($current_user_id) {
+ $settings_row = $wpdb->get_row(
+ $wpdb->prepare(
+ "SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %d",
+ $current_user_id
+ ),
+ ARRAY_A
+ );
+ $event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
+ $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];
- return $args;
+ if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
+ $args['post__in'] = array_map('intval', $selected_events);
+ $args['orderby'] = 'post__in';
+ unset($args['author']);
+ }
+ }
+ return $args;
}
/**
From aa6a5af7c65d0d4c167d1f5751195eb1d8e9a3ac Mon Sep 17 00:00:00 2001
From: Roshani
Date: Thu, 21 Aug 2025 18:18:02 +0530
Subject: [PATCH 165/171] #223 Code issue
---
includes/wpem-rest-crud-controller.php | 12 +-----
includes/wpem-rest-events-controller.php | 55 ------------------------
2 files changed, 1 insertion(+), 66 deletions(-)
diff --git a/includes/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
index e721667..6d2fa21 100644
--- a/includes/wpem-rest-crud-controller.php
+++ b/includes/wpem-rest-crud-controller.php
@@ -434,19 +434,9 @@ public function get_items( $request ) {
if ($auth_check) {
return self::prepare_error_for_response(405);
} else {
- /*$settings_row = $wpdb->get_row("SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys LIMIT 1", ARRAY_A);
-
- $event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
- $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];*/
-
+
$query_args = $this->prepare_objects_query($request);
- /*if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
- $query_args['post__in'] = array_map('intval', $selected_events);
- $query_args['orderby'] = 'post__in';
- unset($query_args['author']);
- }*/
-
$query_results = $this->get_objects($query_args);
$objects = array();
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index e5dcc5f..2db7b39 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -917,61 +917,6 @@ public function get_event_texonomy( $texonomy = '' ) {
}
return $data;
}
- public function get_items( $request ) {
- global $wpdb;
-
- $user_id = intval( $request['user_id'] );
- $auth_check = $this->wpem_check_authorized_user( $user_id );
- if ($auth_check) {
- return parent::get_items($request);
- } else {
- $query_args = $this->prepare_objects_query($request);
-
- $settings_row = $wpdb->get_row(
- $wpdb->prepare(
- "SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %d",
- $user_id
- ),
- ARRAY_A
- );
-
- $event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
- $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];
-
- if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
- $query_args['post__in'] = array_map('intval', $selected_events);
- $query_args['orderby'] = 'post__in';
- unset($query_args['author']);
- }
-
- $query_results = parent::get_objects($query_args);
-
- $objects = array();
- foreach ($query_results['objects'] as $object) {
- $object_id = isset($object->ID) ? $object->ID : $object->get_id();
-
- if (!wpem_rest_api_check_post_permissions($this->post_type, 'read', $object_id)) {
- continue;
- }
-
- $data = $this->prepare_object_for_response($object, $request);
- $objects[] = $this->prepare_response_for_collection($data);
- }
-
- $page = isset($query_args['paged']) ? (int) $query_args['paged'] : 1;
- $total_pages = ceil($query_results['total'] / $query_args['posts_per_page']);
-
- $response_data = self::prepare_error_for_response(200);
- $response_data['data'] = array(
- 'total_post_count' => isset($query_results['total']) ? $query_results['total'] : null,
- 'current_page' => $page,
- 'last_page' => max(1, $total_pages),
- 'total_pages' => $total_pages,
- $this->rest_base => $objects,
- );
- return wp_send_json($response_data);
- }
- }
}
new WPEM_REST_Events_Controller();
\ No newline at end of file
From ed579490b2345c6967c228cd014062ca7458ed1b Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 22 Aug 2025 15:48:52 +0530
Subject: [PATCH 166/171] #223 Code issue
---
includes/wpem-rest-events-controller.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index 2db7b39..4c6e434 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -243,6 +243,7 @@ protected function prepare_objects_query( $request ) {
// Get current user ID
$current_user_id = wpem_rest_get_current_user_id();
if ($current_user_id) {
+ global $wpdb;
$settings_row = $wpdb->get_row(
$wpdb->prepare(
"SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %d",
From edb1bea858b430c92657b929cc170a70b429875c Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 22 Aug 2025 17:06:22 +0530
Subject: [PATCH 167/171] Revert "#223 Code issue"
This reverts commit ed579490b2345c6967c228cd014062ca7458ed1b.
---
includes/wpem-rest-events-controller.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index 4c6e434..2db7b39 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -243,7 +243,6 @@ protected function prepare_objects_query( $request ) {
// Get current user ID
$current_user_id = wpem_rest_get_current_user_id();
if ($current_user_id) {
- global $wpdb;
$settings_row = $wpdb->get_row(
$wpdb->prepare(
"SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %d",
From 27b55b350a92d4c4ccbe43a433a46ed995349b93 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 22 Aug 2025 17:06:41 +0530
Subject: [PATCH 168/171] Revert "#223 Code issue"
This reverts commit aa6a5af7c65d0d4c167d1f5751195eb1d8e9a3ac.
---
includes/wpem-rest-crud-controller.php | 12 +++++-
includes/wpem-rest-events-controller.php | 55 ++++++++++++++++++++++++
2 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/includes/wpem-rest-crud-controller.php b/includes/wpem-rest-crud-controller.php
index 6d2fa21..e721667 100644
--- a/includes/wpem-rest-crud-controller.php
+++ b/includes/wpem-rest-crud-controller.php
@@ -434,9 +434,19 @@ public function get_items( $request ) {
if ($auth_check) {
return self::prepare_error_for_response(405);
} else {
-
+ /*$settings_row = $wpdb->get_row("SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys LIMIT 1", ARRAY_A);
+
+ $event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
+ $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];*/
+
$query_args = $this->prepare_objects_query($request);
+ /*if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
+ $query_args['post__in'] = array_map('intval', $selected_events);
+ $query_args['orderby'] = 'post__in';
+ unset($query_args['author']);
+ }*/
+
$query_results = $this->get_objects($query_args);
$objects = array();
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index 2db7b39..e5dcc5f 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -917,6 +917,61 @@ public function get_event_texonomy( $texonomy = '' ) {
}
return $data;
}
+ public function get_items( $request ) {
+ global $wpdb;
+
+ $user_id = intval( $request['user_id'] );
+ $auth_check = $this->wpem_check_authorized_user( $user_id );
+ if ($auth_check) {
+ return parent::get_items($request);
+ } else {
+ $query_args = $this->prepare_objects_query($request);
+
+ $settings_row = $wpdb->get_row(
+ $wpdb->prepare(
+ "SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %d",
+ $user_id
+ ),
+ ARRAY_A
+ );
+
+ $event_show_by = isset($settings_row['event_show_by']) ? $settings_row['event_show_by'] : '';
+ $selected_events = isset($settings_row['selected_events']) ? maybe_unserialize($settings_row['selected_events']) : [];
+
+ if ($event_show_by === 'selected' && !empty($selected_events) && is_array($selected_events)) {
+ $query_args['post__in'] = array_map('intval', $selected_events);
+ $query_args['orderby'] = 'post__in';
+ unset($query_args['author']);
+ }
+
+ $query_results = parent::get_objects($query_args);
+
+ $objects = array();
+ foreach ($query_results['objects'] as $object) {
+ $object_id = isset($object->ID) ? $object->ID : $object->get_id();
+
+ if (!wpem_rest_api_check_post_permissions($this->post_type, 'read', $object_id)) {
+ continue;
+ }
+
+ $data = $this->prepare_object_for_response($object, $request);
+ $objects[] = $this->prepare_response_for_collection($data);
+ }
+
+ $page = isset($query_args['paged']) ? (int) $query_args['paged'] : 1;
+ $total_pages = ceil($query_results['total'] / $query_args['posts_per_page']);
+
+ $response_data = self::prepare_error_for_response(200);
+ $response_data['data'] = array(
+ 'total_post_count' => isset($query_results['total']) ? $query_results['total'] : null,
+ 'current_page' => $page,
+ 'last_page' => max(1, $total_pages),
+ 'total_pages' => $total_pages,
+ $this->rest_base => $objects,
+ );
+ return wp_send_json($response_data);
+ }
+ }
}
new WPEM_REST_Events_Controller();
\ No newline at end of file
From 60116eb89b77d486f90f169d73cd81143896f809 Mon Sep 17 00:00:00 2001
From: Roshani
Date: Fri, 22 Aug 2025 18:15:57 +0530
Subject: [PATCH 169/171] #223 Solve critical error
---
includes/wpem-rest-events-controller.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index e5dcc5f..8273c6d 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -243,6 +243,7 @@ protected function prepare_objects_query( $request ) {
// Get current user ID
$current_user_id = wpem_rest_get_current_user_id();
if ($current_user_id) {
+ global $wpdb;
$settings_row = $wpdb->get_row(
$wpdb->prepare(
"SELECT event_show_by, selected_events FROM {$wpdb->prefix}wpem_rest_api_keys WHERE user_id = %d",
From ebf463f240b00a721ef32d8a998a7aeb1bec93cd Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 25 Aug 2025 10:27:12 +0530
Subject: [PATCH 170/171] unable to add user #227
---
admin/wpem-rest-api-settings.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/admin/wpem-rest-api-settings.php b/admin/wpem-rest-api-settings.php
index e3cffce..ddb204d 100644
--- a/admin/wpem-rest-api-settings.php
+++ b/admin/wpem-rest-api-settings.php
@@ -140,10 +140,9 @@ public function output() {
From 8569f9d9d7fa09b245d9636525e59c0347c25abb Mon Sep 17 00:00:00 2001
From: Rita
Date: Mon, 25 Aug 2025 10:33:57 +0530
Subject: [PATCH 171/171] unable to add user #227
---
includes/wpem-rest-events-controller.php | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/includes/wpem-rest-events-controller.php b/includes/wpem-rest-events-controller.php
index 8273c6d..74c459c 100644
--- a/includes/wpem-rest-events-controller.php
+++ b/includes/wpem-rest-events-controller.php
@@ -204,7 +204,8 @@ public function prepare_object_for_response( $object, $request ) {
*/
protected function prepare_objects_query( $request ) {
$args = parent::prepare_objects_query( $request );
-
+ // Get current user ID
+ $current_user_id = wpem_rest_get_current_user_id();
// Set post_status.
if( isset( $request['status'] ) && $request['status'] !== 'any' ) {
$args['post_status'] = $request['status'];
@@ -237,11 +238,8 @@ protected function prepare_objects_query( $request ) {
$args['tax_query'] = $tax_query; // WPCS: slow query ok.
}
- $args['author'] = wpem_rest_get_current_user_id();
$args['post_type'] = $this->post_type;
- // --- Event selection logic ---
- // Get current user ID
- $current_user_id = wpem_rest_get_current_user_id();
+ // --- Event selection logic ---
if ($current_user_id) {
global $wpdb;
$settings_row = $wpdb->get_row(
@@ -258,7 +256,11 @@ protected function prepare_objects_query( $request ) {
$args['post__in'] = array_map('intval', $selected_events);
$args['orderby'] = 'post__in';
unset($args['author']);
+ } else {
+ $args['author'] = $current_user_id;
}
+ } else {
+ $args['author'] = $current_user_id;
}
return $args;
}