Free Directory, Listing & Classifieds WordPress Plugin Support General HivePress Override user-login to use wp-login.php

Override user-login to use wp-login.php

  • Author
    Posts
  • tonyjhughes

    Hi,

    I’m looking to use a 3rd party authentication provider (Auth0) which works by redirecting from wp-login.php to the authentication service. (Save’s me holding any passwords in my DB, only tokens!)

    Is there a way to override the user_login_page redirects so it goes to wp-login.php?

    I have already customised ‘user-login-link.php’ which has sorted the header link to the modal, however other links (such as ‘add listing’) redirect to the sign-up page when not authenticated.

    Thanks,
    Tony

    ihordeveloper

    Try using this code snippet:

    add_action(
    	'template_redirect',
    	function() {
    		if ( function_exists( 'hivepress' ) && hivepress()->router->get_current_route_name() === 'user_login_page' ) {
    			wp_safe_redirect( 'custom url here' );
    
    			exit;
    		}
    	}
    );

    But please note that this will break the front-end redirects, e.g. when user clicks on “Add Listing”, and then signs in, user is redirected to the first step of the listing submission process. If you redirect user to another login page there will be no redirect back, so there may be bad UX. Also, there’re a lot of links to the login popup added by extensions (e.g. favorites, messages).

    You can consider using the WordPress authentication to avoid these issues, it doesn’t store plain text passwords anyways, only hashes.

    tonyjhughes

    Hi ihor,

    That works, I will need to check through all the other touch points where the modal is used and see if I can do anything there.

    I’ve just tested using the WP “redirect_to=” and this works so long as whitelist the return URI from within Auth0, which is a start! Looks like I have some work to do!

    Security wins over UX for me 🙂

    letsgetdelivery

    Or use a rock-solid password hashing like bcrypt.

    tonyjhughes

    @letsgetdelivery – I may have to. I said security wins over UX but I ain’t going to make this work without a lot of customisation! Time to research hashing, I’ll look at bcrypt. And also see if there are any other tips out there on DB security.

    unitehearts

    @tonyjhughes – am curious to know how it is coming along

    issab

    @unitehearts how did you put the whatsapp, Instagram icon on your listings card?

    unitehearts

    @issab – i can see that you have asked this question here
    Post Link: https://hivepress.io/support/topic/hivepress-showcase/page/4/#post-3128
    I copied it from that thread only – you will see it written there

    unitehearts

    @tonyjhughes can you please share how you changed the modal – as you said here “I have already customised ‘user-login-link.php’ which has sorted the header link to the modal”

    Please share – i have a similar issue.

    Thanks

    ihordeveloper

    I guess @tonyjhughes meant overriding this template part and setting the login page URL instead of the modal URL https://github.com/hivepress/hivepress/blob/master/templates/user/login/user-login-link.php

    unitehearts

    @ihor – Thank you very much for replying.
    If I replace <a href=”#user_login_modal” with <a href=”my-custom-url/” then will this not be removed by an update of Hivepress ? How can I do it in a proper way to protect this from updates ?
    Please advise.

    ihordeveloper

    You can override the template part without editing the plugin files, please check the instructions in this topic https://hivepress.io/support/topic/counting-interactions/

    tonyjhughes

    Hi Guys,
    Sorry, been busy with my actual job…


    @ihor
    – you were correct, I just changed it directly in user-login-link.php


    @unitehearts
    – I gave up on implementing Auth0 for user authentication for now. There’s are alot more touchpoints on the user journey where there’s either a login modal or link to login/register page.

    Places where these are: Header (login/my account); Reply to Listing; Add To Favourites; Listing Reply & Favourite buttons on the listing card..

Viewing 13 posts - 1 through 13 (of 13 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.