Add listing button redirect for non logged-in visitors

Hello guys,

Please help me.

  1. Current situation:
    Previously I’ve implemented this snippet for my Add listing button that opens a registration modal window for non-logged in visitors:
add_filter(
	'hivepress/v1/templates/user_login_page',
	function($template){
		$redirect_url = hivepress()->router->get_redirect_url();
		
		if(!$redirect_url || strpos($redirect_url, 'submit-listing') === false){
			return $template;
		}
		
		hivepress()->template->fetch_block($template, 'user_login_form');
		
		return hivepress()->template->merge_blocks(
			$template,
			[
				'page_content' => [
					'blocks' => [
						'page_title' => [
							'type' => 'content',
							'content' => '<h1 class="hp-page__title">Registration</h1>',
						],
						
						'user_login_form' => [
							'type'   => 'user_register_form',
							'_order' => 10,
						],
					],
				],
			]
		);
	},
	1000
);

Currently when vistor is not signed-in when he pushes the add listing button in the header the url is the following: (https://geo-task.com/account/login/?redirect=https%3A%2F%2Fgeo-task.com%2Fsubmit-listing%2F) and registration modal opens up. Works fine. :ok_hand:

And now I would like to change it in a way that when not signed-in or not registered visitor is pushing the Add listing button he should be redirected to register-vendor page (for direct vendor registration upon this button).

I found this snippet on GitHub:

add_filter('hivepress/v1/routes', function($routes) {
    $routes['listing_submit_page']['path']='/custom-slug-here'; // I add here "register-vendor"

    return $routes;
}, 1000);

I think this will work for both cases for signed-in and for signed-out users. I need only for signed-out.
My knowledges are not enough for customizing it.

Please help me to do that.

I want to keep the original process for logged-in users when they push add listing button being signed-in.

  1. Also I’ve noticed, that after I’ve activated the direct vendor registration - when the user signs-in for the first time - he is not redirected to complete vendor profile. How I can implement it?

The thing is that when you register via simple registration form or through an add listing button now (not via register-vendor direct link) - when you follow the e-mail confirmation link you are being automatically signed-in + complete vendor profile shows up + add listing page shows up next.

But when you register via direct vendor registration link and follow confirmation link from the e-mail - you are not automatically signed-in + when you log-in manually the complete vendor registration form is not open up.

Let me try to explain - I want to implement direct vendor registration in such a way, so that the initial process should be the same if you register when it’s not activated.
The reason of this is that I want vendors (who registered via direct vendor registration link) to show their profiles even if they don’t add a listing but at the same time the system should offer them to add listing after they complete their vendor’s profile but it should not be obligatory. If they miss the add listing step their profile will be published in any case. This is my idea.

I would like to leave the original process that allows you (as a direct vendor) to automatically sing-in via confirmation link from the e-mail, automatically open a complete vendor profile page upon first sign-in and then automatically offer to complete listing profile (but in this case the last point will be not obligatory and this will allow to show the vendor profile even if he didn’t added a listing).

Sorry, maybe it’s a bit complicated but I don’t know how to explain easier. :sweat_smile:

1 Like
  1. Unfortunately, there is no such possibility that a user needs to be logged in or registered to visit the direct vendor registration page. But the PHP snippet below maybe can solve this task as it will redirect a user from the login page/form to the direct vendor registration page. It is needed testing

  2. Please try this PHP snippet, but please note that it can require additional testing

add_filter(
	'hivepress/v1/forms/user_login',
	function($form){
		$form['redirect'] = hivepress()->router->get_url( 'vendor_register_page' );
		return $form;
	},
	1000
);
1 Like

Hi Yevhen,
Sorry, maybe my explanation was really complicated.
What I was trying to say is that I would like to make the following:

When a non signed-in user/vistor pushes the button “Add listing” (in the header) he should be redirected to /register-vendor page. Now by default he is directed to a simple user registration page.

So the aim is to make a redirect for this button for signed-out users to /register-vendor page.

But at the same time my desire is to keep the original flow for this button for signed-in users - so if the user is signed-in if the push the button Add listing - he is transferred to submit listing page or completion of vendors’ profile in case it’s empty. Like it is now.

Maybe there is a possible solution to implement these both terms at the same time?

Thank you for the details. Unfortunately, there is a restriction that the user needs to be registered to become vendor with direct vendor registration. But the provided code snippet above redirects users when they authenticate successfully. So, after the successful registration or login, the non-vendor user will be redirected to the direct vendor registration page. But it needs additional on your website. If I understand you correctly, then this code snippet solves these two issues

Hi Yevhen,

Original question:
Let’s forget about those snippets above for now. Let me try to explain with a screenshot:

New question:

Finally, what I was trying to say in previous posts - is that I want to fully replace the default vendor registration flow with a direct vendor registration flow.

Look, in the default vendor registration process it goes like this.
You are not signed-in and you don’t have an account yet. You want to become a Vendor. You push the “Add Listing” button and it shows you sing-in\up modal — or you register via authorization form doesn’t matter.

So when you try to add listing first of all you are asked to fill out your Vendor’s profile and the link at this step is the following: my-site/submit-listing/profile/.
Once you complete this profile you automatically see next step with add listing details screen. And the link at this step is the following: my-site/submit-listing/details/.
Until you add at least one listing your profile won’t be published.

I would like to know if it’s possible to somehow replace my-site/submit-listing/profile/ url with my-site/register-vendor and once the vendor is registered to forward him to add listing page my-site/submit-listing/details/?
Currently if Vendor is register via my-site/register-vendor the next step is his public profile view.

My idea here is simple. If Vendor doesn’t want to post a listing, his profile is published anyway. But at the same time we should offer him this opportunity and after he submits his profile - to show him add listing page. And he decides whether to fill it now or later. But his profile is already published.

I want to implement it instead of default flow because it’s impossible to explain users that there are two ways to become a Vendor - with posting a listing and without. It’s very complicated, because those two ways are working at the same time!

I believe that it would be better if: once you activate a direct registration, the default flow should be disabled or it’s just a Bermuda Triangle to my mind.

Guys,

Kindly advise can I convert those who already registered as a vendor via default flow and didn’t add listing (with subscriber role) can I publish their profiles manually from admin panel (in terms they don’t have listings yet)?

For example if I change their roles from subscriber to contributor will their vendor profiles published or not?

Thank you in advance.

1 Like

Hi,

  1. There’s no easy way to do it, please consider hiring someone on Fiverr to help you https://fvrr.co/32e7LvY

  2. You can publish or unpublish vendors in the WP Dashboard > Vendors section. If a user registered as a vendor via direct registration, it should be shown on the front-end. But simple changing the user’s status from “subscriber” to “contributor” won’t create a new vendor profile.

1 Like

Hey Artem,
just want to say thanks for the code snippet on here. It works a treat!
I too have been trying to find a similar solution to the register form or make it super easy for a business to add their details and have it listed immediately.

Very new to all of this but still looking at ways to do it or eventually may have to get a developer to do it.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.