| @@ -6,9 +6,11 @@ | ||
| 6 | 6 | if ( check_ajax_referer( 'wppm_create_project', '_ajax_nonce', false ) != 1 ) { |
| 7 | 7 | wp_send_json_error( 'Unauthorised request!', 401 ); |
| 8 | 8 | } |
| 9 | 9 | $wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true ); |
| 10 | -if (($current_user->has_cap('manage_options')) || $wppm_current_user_capability == 'wppm_manager'|| $wppm_current_user_capability == 'wppm_admin') { | |
| 10 | +$wppm_can_create_project = ($current_user->has_cap('manage_options')) || $wppm_current_user_capability == 'wppm_manager'|| $wppm_current_user_capability == 'wppm_admin'; | |
| 11 | +$wppm_can_create_project = apply_filters( 'wppm_can_create_project', $wppm_can_create_project, $current_user->ID ); | |
| 12 | +if ($wppm_can_create_project) { | |
| 11 | 13 | // project name |
| 12 | 14 | $name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : ''; |
| 13 | 15 | if($name) $args['name'] = $name; |
| 14 | 16 | |
| @@ -56,7 +58,9 @@ | ||
| 56 | 58 | } |
| 57 | 59 | $auth_code = $wppmfunction->getRandomString(10); |
| 58 | 60 | $wppmfunction->add_project_meta($project_id,'public_project',$public_proj); |
| 59 | 61 | $wppmfunction->add_project_meta($project_id,'project_auth_code',$auth_code); |
| 62 | +} else { | |
| 63 | + wp_send_json_error( 'Permission denied', 403 ); | |
| 60 | 64 | } |
| 61 | 65 | |
| 62 | -do_action('wppm_after_project_created',$project_id); | |
| 66 | +do_action('wppm_after_project_created',$project_id); | |