| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
global $current_user, $wppmfunction ,$wpdb; |
| 6 |
$project_id = isset($_POST['project_id']) ? absint(sanitize_text_field(wp_unslash($_POST['project_id']))) : 0 ; |
| 7 |
$project_data = $wppmfunction->get_project($project_id); |
| 8 |
$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); |
| 9 |
$is_archived = (isset($_POST['is_archived']) && absint(sanitize_text_field(wp_unslash($_POST['is_archived']))) == 1) ? 0 : 1 ; |
| 10 |
if( $wppm_current_user_capability == 'wppm_admin' || $current_user->has_cap('manage_options') || $project_data['created_by']==$current_user->ID){ |
| 11 |
$values=array( |
| 12 |
'is_archived'=>$is_archived |
| 13 |
); |
| 14 |
$wpdb->update($wpdb->prefix.'wppm_project', $values, array('id'=>$project_id)); |
| 15 |
} |