Hello, is there a way I can generate a new page for each vendor like /vendor/johndoe/xxx. The contents are not important, just need to have one new page for each vendor.
Thanks
Hello, is there a way I can generate a new page for each vendor like /vendor/johndoe/xxx. The contents are not important, just need to have one new page for each vendor.
Thanks
Hi,
Please provide more details on which page you are referring to. Also, should the layout be vendor-based or text-based? Please note that in any case, this will require a custom implementation. If you are familiar with coding or have a developer, we can provide you with general guidance.
Hi andrii,
For each vendor I want to create a new page with a plugin for a video call. For example, if I have a vendor called John Doe, he’s vendor page /vendor/johndoe, so his/hers page for video calls would be page/vendor/johndoe/videocall.
I do have experience as a developer, I tried this approach in the function.php file
// Register a custom endpoint for the video call page
add_action( 'init', 'register_vendor_video_call_endpoint' );
function register_vendor_video_call_endpoint() {
// Register 'videocall' endpoint for vendors
add_rewrite_endpoint( 'videocall', EP_PAGES );
}
// Hook into the HivePress vendor page template
add_filter( 'hivepress/v1/templates/vendor_view_page', 'add_videocall_to_vendor_profile' );
function add_videocall_to_vendor_profile( $template ) {
$template['blocks']['vendor_videocall'] = [
'type' => 'part',
'path' => 'vendor-videocall',
];
return $template;
}
// Load content for the custom endpoint
add_action( 'hivepress/v1/templates/vendor_view_page/vendor_videocall', function() {
global $wp_query;
if ( isset( $wp_query->query_vars['videocall'] ) ) {
// Get the current vendor
$vendor = hivepress()->vendor->get_current_vendor();
if ( $vendor ) {
// Generate a unique Jitsi room based on the vendor's name
$jitsi_room = sanitize_title( $vendor->get_name() );
echo '<h2>' . esc_html( $vendor->get_name() ) . '\'s Video Call</h2>';
echo '<iframe src="https://meet.jit.si/' . $jitsi_room . '" style="width: 100%; height: 600px; border: 0;"></iframe>';
}
}
});
Not really know the difference between vendor-based or text-based.
We can provide general guidance regarding this, but unfortunately we can’t verify or debug specific customizations further, this is beyond the support scope.
Please try using the hivepress/v1/routes
hook to add a new route with a path like /vendor/{username}/videocall
, and set redirect and render functions for it. The redirect function decides if users can access the page (e.g. find a vendor by username from URL, check if the vendor exists, if not then redirect users away by returning true
). The render function should return HTML to render.
This way you can add a custom page based on a new URL route. You can find more details here https://docs.hivepress.io/developer-docs/framework/controllers#template-routes and here https://docs.hivepress.io/developer-docs/framework/templates
Hope this helps
We adding the route, what should be base parameter? I’m following this, on the link you provided
To define a new URL route, add an array of the following parameters:
title - text used as the page title and [menu](https://docs.hivepress.io/> developer-docs/framework/menus) label;
path - the relative route URL path (starts with a slash);
base - the route name to inherit the
path
from;redirect - points to the route redirect function;
action - points to the route action function.
It’s ok to not set the “base” parameter, but it’s important to set “path”, you can try this one:
/vendor/(?P<username>[A-Za-z0-9 _.\-@]+)/videocall
Then if you refresh permalinks in Settings/Permalinks and try to access a valid vendor page with “/videocall” at the end, then functions which you set for the “redirect” and “action” route parameters should run. In these functions, you can fetch username from the URL this way:
hivepress()->router->get_param('username')
Then query the vendor profile, check if it exists at all, etc.
Hope this helps
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.