Okay
  Public Ticket #4532795
How to force reset password on first login
Open

Comments

  • Marco started the conversation

    Hello Support Team,

    I’m working on a WordPress + WooCommerce site using SalesKing (agents) and B2BKing. I need to enforce a security policy where SalesKing agents must reset/change their password on their first login. Until the password is changed, the agent should not be able to access either the agent dashboard page or wp-admin.

    I attempted:
        •    A custom implementation (flagging users via user meta and redirecting to a forced password-change page)
        •    A third-party plugin (e.g., Melapress Login Security)

    However, it looks like SalesKing (and possibly B2BKing) overrides the login flow and performs a redirect to the agent dashboard very early (e.g., redirect + exit), which prevents standard WordPress hooks like login_redirect or WooCommerce login redirect filters from reliably enforcing the password reset.

    Could you please advise:
        1.    Whether SalesKing provides an official way (setting/hook/filter) to force a password reset/change on first login for agent users.
        2.    If there is a recommended hook or integration point to override the default “redirect to agent dashboard” behavior until the password is updated.
        3.    Any known conflicts with B2BKing or WooCommerce login redirects related to this use case.

    If useful, I can share logs/stack traces showing the redirect being triggered from the SalesKing login handler.

    Thank you,
    Marco

  •  2,624
    WebWizards replied

    Hi Marco,

    Thanks for reaching out,

     

    SalesKing does not have a specific login redirect - what it actually does technically is that is just loads different templates based on the status of the current user. This is the relevant code that chooses to load either the login form, or the agent dashboard, or a message telling the user they're not an agent:

    5061899793.png

     

    I'm thinking a good way to solve this would be to modify 'salesking-dashboard.php'. This is our template that normally loads the dashboard. 

    I'm thinking that at the very beginning of this template, we could check a usermeta (e.g. 'has_already_reset') and if not set, wp_redirect() to your password reset page.

     

    It is possible to modify salesking-dashboard.php by following the guide here: https://woocommerce-b2b-plugin.com/docs/how-to-edit-salesking-dashboard-page-templates/ - this will involve copying the template to the child theme.

     

    Happy to look into it directly if that would help - for that, I would need a backend login to your site or a staging clone site,

    Kind regards,

    Stefan