customize new room function
-
Hello I want to customize new room part and add one more field of select user and save that field. I already override template in upload folder path
upload/wikibooking/override/admin/manageroo/default.php
and additional dropdown can you tell me how to save that field without changing core files
-
Hello,
Thanks for your detailed message. Thanks to the overrides you can alter the HTML/JS structure of any front-end or back-end page of Vik Booking as you’ve noticed, but it is not possible to execute additional queries to save, for example, additional data for your room. In this case, it is necessary to use a custom WordPress plugin and register to a specific hook that will be fired when clicking the Save button for creating or updating a room.
If you subscribe to the hook
vikbooking_before_dispatch
you can register a callback function that will be fired whenever a page or a task of Vik Booking is displayed/executed.With this callback function you should check the request variables to identify the type of task/operation requested (i.e. save/update/delete room). On top of that, you probably want to use some WordPress native functions like
is_admin()
to make sure you operate only if within the wp-admin section.
Once you have identified the type of action (task or view) through the request variables, you can perform any kind of operation onto the database, to save for example an additional information about your room.This is how you can save, update or delete custom information without editing any core files. As you’ve noticed, the only solution is to use the hooks fired by our plugin, and so you need a custom WordPress plugins to subscribe to that event (hook).
On a side note, we would like to remind you that Vik Booking is certified as a single-vendor booking engine, in the sense that a portal with multiple owners and properties could not be achieved with our plugin, due to its certification with the complementary Channel Manager service. OTAs would never certify a multi-vendor system as a Channel Manager provider. For the rest, you are free to implement any sort of custom feature you want.
We hope this helps!
The VikWP Team
hello
First of all thanks for the support
I have used hook as per your suggestion and this is the code
add_action( ‘vikbooking_before_dispatch’, ‘room_add_custom_function’, 10, 3 );
function room_add_custom_function( ) {
$task = JFactory::getApplication()->input->get(‘task’);
$app = JFactory::getApplication();
$user = Jfactory::getUser();
if ($app->isAdmin())
{
if($task == ‘createroom’ ||($task == ‘createroomstay’ )
{
$host_user = VikRequest::getVar(‘host_user’, ” , ‘request’);
die($host_user);
}
}
}I also getting the value of user as well. Now the problem is that the hook is run before the room data is inserted in the DB, so how do I get the room insert id to save the user data with the same room id?
any help really appreciated
Hello,
Thanks for posting an example of code. Please notice that you can access the request variables also through WordPress native functions. Otherwise, you can use the classes prefixed with
Vik
and defined by Vik Booking, includingVikFactory::getApplication()->input
andVikFactory::getUser()
to respectively access the request-input object and the currently logged in WordPress user. Of course such classes rely on WordPress native functions, but since yours is a custom plugin just for WordPress, you could just use the WP core functions.In case of the creation of a new room, the hook “before_dispatch” will run before the room record is actually validated and stored onto the database. You can try using the hook
vikbooking_after_dispatch
, but this may not always run in case the process is truncated with a redirection by the main controller.The best solution is to implement this feature when you are updating an existing room record, and in this case the ID of the room (record) will be available in the request variables. Since there is no specific hook for when a room ID is created, updated or deleted, the only solution is to use the two hooks of the MVC dispatcher in Vik Booking, which are called respectively
vikbooking_before_dispatch
andvikbooking_after_dispatch
. In case your code can run also in the “after_dispatch” hook (event), all you need to do is to query the database to grab the newly created room-record by using the name or any other value available in the request variables.Otherwise, implementing your modification only when updating a room would be much easier, as you have already the ID of the record to be updated.
We hope this helps!
okay
Thank you so much for the supportHello i have installed wordpress multisite in server in which i have used two subdomain app and list. I have vikbooking booking uploaded and network is active. I have bought vikbooking pro version and added the key, it just upgrade vikbooking plugin pro to main domain only. my question is how to use pro version in full multisite??
Main concept is room added by app sub domain and booking done by list sub domain and main domain for marketing purpose i already used “vik_get_db_prefix” to share same data in whole siteHello,
By default, Vik Booking will get its own database tables on any new sub-site in the network. You don’t want this to happen if you want all sub-sites of the multi-site network to share the same information in Vik Booking. In this case, you need a plugin that unifies the database tables prefix for all sub-sites of the network. We do have one available, but you should contact us through our website so that we can send it to you. It’s a simple one-file plugin that simply uses the “base prefix” declared by WordPress. This simple plugin only declares a “hook” with WordPress.
In any case, for such technical requests, we prefer if you can get in touch with our technical team through our website, as this is something that only refers to a multi-site network where all sub-sites should read the same information from Vik Booking.
Hello
It is not my question that I have already done this by creating a mu plugin that is code
// The filter callback function for vik_get_db_prefix function bookinter_table_prefix() { global $wpdb; return $wpdb->base_prefix; } add_filter( 'vik_get_db_prefix', 'bookinter_table_prefix' );
my question is how to use pro version in full multisite??
I have to buy three different licenses for that?
I have activated pro verioson by license key in main domain how to activate in subdomain?Hello,
Thanks for posting the code. That’s exactly what the plugin I was telling you about does. This way the same database table prefix will be used for all sub-sites of the network.
However, you don’t need to purchase one license for each sub-site at all, because of course the 3 Vik Booking installations should all be considered as “Pro”. The point is that the License Key is stored on the WordPress native
_options
table, and so this may be available for each sub-site of the network.Our suggestion is to try to perform the “Upgrade to Pro” process on all sub-sites, but all the sub-installations should all be in the “Pro” version. Just make sure to install the updates for the main plugin Vik Booking only from the main site.
- The topic ‘customize new room function’ is closed to new replies.