ID); return new WP_REST_Response( $properties, 200 ); } function bc_select_properties_for_user($userId){ global $wpdb; $sql = $wpdb->prepare("SELECT * FROM wp_rental_properties WHERE user_id = %d;", $userId); return $wpdb->get_results($sql, OBJECT); } function bc_select_property($userId, $propertyId){ global $wpdb; $sql = $wpdb->prepare("SELECT * FROM wp_rental_properties WHERE user_id = %d AND id = %d;", $userId, $propertyId); return $wpdb->get_row($sql); } function bc_update_property( WP_REST_Request $request ) { global $wpdb; global $current_user; $response = new WP_REST_Response(); $userId = $current_user->ID; $table_name = $wpdb->prefix."rental_properties"; $data = $wpdb->update($table_name, array( 'rental_name' => $request['rental_name'], 'address1' => $request['address1'], 'address2' => $request['address2'], 'city' => $request['city'], 'state' => $request['state'], 'zip' => $request['zip'] ), array( 'id' => $request['id'], 'user_id' => $userId, )); if(!empty($request['redirect'])){ $response->set_status( 302 ); $response->header('Location', $request['redirect']); return $response; } $response->data = $data; $response->set_status( 201 ); return $response; } function bc_create_property( WP_REST_Request $request ) { global $wpdb; global $current_user; $response = new WP_REST_Response(); if(!bc_user_can_add_property($current_user->ID)) { $response->set_status(400); $response->data = array( 'error' => 'Subscription plan unit count exceeded.' ); return $response; } $userId = $current_user->ID; $table_name = $wpdb->prefix."rental_properties"; $data = $wpdb->insert($table_name, array( 'user_id' => $userId, 'rental_name' => $request['rental_name'], 'address1' => $request['address1'], 'address2' => $request['address2'], 'city' => $request['city'], 'state' => $request['state'], 'zip' => $request['zip'] )); if(!empty($request['redirect'])){ $response->set_status( 302 ); $response->header('Location', $request['redirect']); return $response; } $response->data = $data; $response->set_status( 201 ); return $response; } function bc_delete_property( WP_REST_Request $request ) { global $wpdb; global $current_user; $response = new WP_REST_Response(); $userId = $current_user->ID; $table_name = $wpdb->prefix."rental_properties"; $data = $wpdb->delete($table_name, array( 'id' => $request['id'], 'user_id' => $userId )); $response->data = $data; $response->set_status(201); return $response; } function bc_user_can_add_property($userId){ return true; // temporary allow any number of props $planCount = bc_get_plan_count_for_user($userId); $unitCount = bc_get_unit_count_for_user($userId); return $unitCount < $planCount; } function bc_get_subscription_for_user($userId){ global $wpdb; $metaKey = '_stripe_customer_id'; $sql = $wpdb->prepare(" SELECT s.* FROM wp_fullstripe_subscribers s JOIN $wpdb->usermeta um ON um.meta_value = s.stripeCustomerID AND um.user_id = %d AND um.meta_key = %s ", $userId, $metaKey); return $wpdb->get_row($sql); } function bc_get_plan_count_for_user($userId){ $subscription = bc_get_subscription_for_user($userId); $planId = $subscription->planID; $planUnitCount = 1; if($planID === ''){ } else if ($planID === ''){ } else if ($planID === ''){ } return $planUnitCount; } function bc_get_unit_count_for_user($userId){ global $wpdb; $sql = $wpdb->prepare("SELECT COUNT(*) FROM wp_rental_properties WHERE user_id = %d", $userId); return $wpdb->get_var($sql); } function bc_get_template( $template ) { $haystack = $template; $needle = 'bauscode'; if ( strpos($haystack, $needle) !== FALSE ) { $page_template = dirname( __FILE__ ) . '/' . $template; } return $page_template; } function bc_rental_shortcode($atts) { ob_start(); include(dirname(__FILE__).'/templates/bauscode-rental-create.php'); $content = ob_get_clean(); return $content; } function bc_plugin_activate(){ bc_init_db_schema(); } function bc_init_db_schema(){ global $wpdb; $table_name = $wpdb->prefix."rental_properties"; if ($wpdb->get_var('SHOW TABLES LIKE '.$table_name) != $table_name) { $sql = 'CREATE TABLE '.$table_name.'( id bigint(20) NOT NULL AUTO_INCREMENT, user_id bigint(20) UNSIGNED NOT NULL, rental_name varchar(50), address1 varchar(50), address2 varchar(50), city varchar(50), state varchar(10), zip varchar(10), PRIMARY KEY (id))'; require_once(ABSPATH.'wp-admin/includes/upgrade.php'); dbDelta($sql); add_option("rental_properties", "1.0"); } } // filters add_shortcode('rental_properties', bc_rental_shortcode); register_activation_hook(__FILE__, bc_plugin_activate); add_action( 'wp_enqueue_scripts', function() { wp_enqueue_script( 'rental_properties', plugin_dir_url( __FILE__ ) . 'rental-properties.js', array( 'jquery' ) ); wp_enqueue_style( 'rental_properties', plugin_dir_url( __FILE__ ) . 'rental-properties.css' ); wp_localize_script('rental_properties', 'RentalProperties', array( 'root' => esc_url_raw( rest_url() ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'current_user_id' => get_current_user_id() ) ); }); // routes add_action( 'rest_api_init', function () { register_rest_route( 'bauscode', '/rental_properties', array( 'methods' => 'GET', 'callback' => 'bc_select_properties', 'args' => array(), 'permission_callback' => function() { return is_user_logged_in(); } ) ); register_rest_route( 'bauscode', '/rental_properties/(?P[\d]+)', array( 'methods' => 'PUT', 'callback' => 'bc_update_property', 'args' => array( 'id' => array(), ), 'permission_callback' => function() { return is_user_logged_in(); } ) ); register_rest_route( 'bauscode', '/rental_properties/(?P[\d]+)/update', array( 'methods' => 'POST', // form-accessible alternate route 'callback' => 'bc_update_property', 'args' => array( 'id' => array(), ), 'permission_callback' => function() { return is_user_logged_in(); } ) ); register_rest_route( 'bauscode', '/rental_properties', array( 'methods' => 'POST', 'callback' => 'bc_create_property', 'args' => array(), 'permission_callback' => function() { return is_user_logged_in(); } ) ); register_rest_route( 'bauscode', '/rental_properties/(?P[\d]+)', array( 'methods' => 'DELETE', 'callback' => 'bc_delete_property', 'args' => array( 'id' => array(), ), 'permission_callback' => function() { return is_user_logged_in(); } ) ); register_rest_route( 'bauscode', '/rental_properties/(?P[\d]+)/delete', array( 'methods' => 'POST', // form-accessible alternate route 'callback' => 'bc_delete_properties', 'args' => array( 'id' => array(), ), 'permission_callback' => function() { return is_user_logged_in(); } ) ); } ); ?> What You Need to Know about Preventing Short Term Renting - Stopbnb Stopbnb

Short-term renting is increasingly popular with tenants, especially since websites like AirBnB, VRBO, and FlipKey have gotten more and more media attention. These websites specialize in giving people access to low-cost short-term rental opportunities in other people’s homes, which is a wonderful concept if it is used properly—and legally.

The problem for you arises when your tenants decide they no longer like the terms of their legally-binding lease and take advantage of these types of websites without asking you first. Your tenant can easily list the property they rent from you as a sublet on these types of websites for any amount of time.

AirBnB, VRBO, and FlipKey users can easily list an apartment for short term renting, or even rent a room while they remain in the apartment or rental property. As the landlord, you must respect your tenant’s privacy, but they must respect your property. To prevent short term renting, it’s important they understand that, and that you understand your options.

To prevent short term renting, you can use the services of StopBnB, which monitors the rental activity of each of your units. While your lease is one safeguard, and even though you can defend yourself with legal action, tenants can be unpredictable and unreliable. Even if you take them to court, you may not win or the tenant might not be solvent enough to pay any damages. StopBnB keeps a close eye on their activity for you, giving you an easy-to-use interface and customizable plans to choose from.