Redirect to login

  • Author
    Posts
  • rafaelvie

    Hi ihor,

    It would be possible to limit or access the seller’s profile according to the print: https://prnt.sc/t73c5o so that when an unauthenticated user clicks on it to display the modal login screen. Or, how to create a redirect to the login page on the listings link as it already exists for the add listings button? Very grateful already!

    ihordeveloper

    Please let me know if you mean redirecting listing or vendor pages? If I understand correctly, non-registered users should be prompted to sign in?

    rafaelvie

    So ihor, i need to see if there is a possibility of a logged out user, when accessing a listing and trying to view the seller’s profile so that the login screen can appear so that he can log in and there he can access the seller’s profile. It would be the same thing as a disconnected user trying to create a listing and the login screen to register. If there is no possibility of this happening (as the print q sent you) it would be possible to redirect to the listtings link to the login screen similar to the add listing redirect. Thanks!

    ihordeveloper

    This code snippet should do it:

    add_action(
    	'template_redirect',
    	function() {
    		if ( ! is_user_logged_in() && is_singular( [ 'hp_listing', 'hp_vendor' ] ) ) {
    			wp_safe_redirect(
    				hivepress()->router->get_url(
    					'user_login_page',
    					[
    						'redirect' => hivepress()->router->get_current_url(),
    					]
    				)
    			);
    
    			exit;
    		}
    	}
    );
    rafaelvie

    Thank you my friend Ihor! Where do I put this snippet? Which file and where in the file do I add this snippet? Is it just for that section that I told you about on the opportunity page or should this redirect be for the link in the listting menu?

    ihordeveloper

    You can add it to the child theme’s functions.php file (if you use one) or via this plugin https://wordpress.org/plugins/code-snippets/

    This redirect works for any listing or vendor page. If you want it to work for the vendor page only please remove the “hp_listing” part.

    rafaelvie

    You are awesome Ihor! Thank you! In my project, the salesperson’s profile will take personal information like address and other data. There it would be interesting only for those who are logged in to see this information. Thank you! HivePress and ListingHive are the best things that have come up for WordPress. Soon I will purchase the other missing paid plugins. The membership and the new one you launched. Hugs!

    rafaelvie

    It worked perfectly! Thank you very much and big hug!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Subscribe

Sign In

Don't have an account? Register

Forgot password?

Register

Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.