roles, true ) ) {
return;
}
// Get current preference
$notify_enabled = get_user_meta( $user->ID, self::META_KEY_NOTIFY, true );
// Create nonce for security
wp_nonce_field( self::NONCE_ACTION, 'ddhh_jm_user_preferences_nonce' );
?>
Benachrichtigungen
roles, true ) ) {
return;
}
// Save preference (checkbox pattern: isset = '1', not set = '0')
$notify_value = isset( $_POST['ddhh_jm_notify_new_jobs'] ) ? '1' : '0';
update_user_meta( $user_id, self::META_KEY_NOTIFY, $notify_value );
}
/**
* Get array of user IDs who have opted in to notifications
*
* @return array Array of user IDs.
*/
public static function get_opted_in_mentors() {
$args = array(
'role' => 'subscriber',
'meta_query' => array(
array(
'key' => self::META_KEY_NOTIFY,
'value' => '1',
),
),
'fields' => 'ID',
);
$user_query = new WP_User_Query( $args );
$user_ids = $user_query->get_results();
// Log if query fails
if ( empty( $user_ids ) && ! is_array( $user_ids ) ) {
error_log( 'DDHH Job Manager: Failed to query opted-in mentors' );
return array();
}
return is_array( $user_ids ) ? $user_ids : array();
}
}