Redirect login and registration forms to custom URLs

Hi!

I’m trying to redirect the login page and the registration default pages to my own pages. I found these snippets on Github but they are not working. I’ve managed to make other snippets work but not these.

add_filter(
	'hivepress/v1/forms/user_login',
	function( $form ) {
		if ( ! isset( $form['redirect'] ) ) {
			$form['redirect'] = '/logga-in';
		}

		return $form;
	},
	1000
);
add_filter(
	'hivepress/v1/forms/user_register',
	function( $form ) {
		if ( ! isset( $form['redirect'] ) ) {
			$form['redirect'] = '/logga-in';
		}

		return $form;
	},
	1000
);

Are they correct and still working with the latest hivepress?

With best regards,

bb

Yes, these snippets are applied only if there’s no current redirect (e.g. no intended action made by user prior to the login form appearing). You can try removing this condition but this may break the action flows:

if ( ! isset( $form['redirect'] ) ) {

Hi ihor and thanks for your swift reply!

I try this but it doesn’t work when I try to go to the edit listings page or add listing page (need to be logged in to see that) while being logged ut. Do you have any other advice?

With best regards,

bb


add_filter(
	'hivepress/v1/forms/user_login',
	function( $form ) {
		
			$form['redirect'] = '/logga-in';
		

		return $form;
	},
	1000
);
add_filter(
	'hivepress/v1/forms/user_register',
	function( $form ) {
		
			$form['redirect'] = '/logga-in';
		

		return $form;
	},
	1000
);

Hi,

Please note that the snippets above do not redirect the initial pages with forms but only after you press the submit button (i.e., when the form has reached a successful status).

Hi and thanks for your answer!

I see. I’m wondering if there’s a way of preventing the plug-in to redirect you to the hivepress login and instead redirect you to a custom login page slug?

With best regards,

bb

Yes, it’s possible but this would require customizations, if you’re familiar with coding please try using the template_redirect hook to catch the “/account/login” URL and redirect it. Please note that sometimes the login form can be opened in the modal window without a redirect. Also, replacing the built-in login redirect may disrupt the Add Listing process (currently the built-in form redirects users to the next step on success).

Hi and thank you!

I’m not… unfortunately. Can you give me a hand if it’s something quickly done? Otherwise I understand completely that I need to hire someone to do it for me.

With best regards,

bb

Hi,

Sorry for the inconvenience, but customization is beyond our support scope - it includes fixing bugs and guidance about the available features Support Policy | HivePress

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

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