Add a new page under vendor like /vendor/johndoe/XXXX

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