add_shortcode('project_cards', function () { if (!is_user_logged_in()) { return ' Please log in to view your projects. '; } global $wpdb; $user_id = get_current_user_id(); // Step 1: Get all project IDs assigned to this user $assigned_project_ids = $wpdb->get_col( $wpdb->prepare( "SELECT proj_id FROM {$wpdb->prefix}wppm_project_users WHERE user_id = %d", $user_id ) ); // Step 2: Get all active projects either created by user or where assigned $project_placeholders = implode(',', array_fill(0, count($assigned_project_ids), '%d')); $query = " SELECT p.id, p.project_name AS title, p.end_date, p.status, p.created_by, pm.meta_value AS group_slug FROM {$wpdb->prefix}wppm_project p LEFT JOIN {$wpdb->prefix}wppm_project_meta pm ON p.id = pm.project_id AND pm.meta_key = 'group_slug' WHERE p.active = 1 AND (p.created_by = %d"; if (!empty($assigned_project_ids)) { $query .= " OR p.id IN ($project_placeholders)"; } $query .= ")"; $params = array_merge([$user_id], $assigned_project_ids); $results = $wpdb->get_results($wpdb->prepare($query, ...$params)); if (empty($results)) { return ' No projects assigned to you yet. '; } ob_start(); echo ' '; foreach ($results as $row) { $group = ucwords(str_replace('-', ' ', $row->group_slug)); $title = esc_html($row->title); $status = esc_html($row->status); $end_date = date('d/m/Y', strtotime($row->end_date)); $days_left = max(0, floor((strtotime($row->end_date) - time()) / 86400)); $link = esc_url(home_url("/groups/{$row->group_slug}/taskbuilder_projects/")); echo ' '; echo " $group "; echo " $title "; echo " Status: $status "; echo " End: $end_date "; echo " Days left: $days_left "; echo "View Project"; echo ' '; } echo ' '; return ob_get_clean(); }); Public Profile

Public Profile

Elinora Inga Sigurdardottir

Elinora Inga Sigurdardottir

Member since 3 years ago

  • 0 Listings

Contact Info

  • sf******@gm***.com

About

Nothing to show!

Achievements

Ranks

Levels

Level 1 ~ Dreamer

The Dreamer

This is the starting level for all members of Ideas-Shared. They are dreamers, full of ambitions, ideas, thoughts, and passion, and just starting out on this journey. As a thank you for joining Ideas-Shared, all new joiners receive a gift of 20 Ambition Points

Points

Ideas-Shared Ambition Point image
21 Ambition Points

Author Listings

Sign up or log in to view my full profile.