10 Comments

  1. Phelan Riessen © says:

    Thanks for posting this Matt. I haven’t had the time to look into proper redirecting logins but it’s been on my list to do for a while. I sometimes get frustrated from my own sites and others always seeing the WP brand login or improper redirects that aren’t UX friendly. Bravo for sharing!

  2. RevConcept says:

    Yo Matt and Devin, wondering what you would suggest for a more complex login scenario (per user): We have a site where my clients create pages specific for their clients…those pages are locked unless a user from a group with permissions to access that page is logged in. We want my client’s clients to be redirected to their page directly after login. This obviously needs to scale as my clients will be creating groups, users and pages on the fly. I’m thinking a login condition that checks 1) they are subscriber role 2) they are a member of a group 3) that group has access to a page using template-x.php — if yes to all three send them to template-x.php Not sure how to run the check for item 3 though… Thoughts?? Currently using: Groups Plugin (https://wordpress.org/plugins/groups/)

    1. Matt Cromwell says:

      Interesting. Off the top of my head I think this could be possible if the URL of the redirect page has a pattern that mimics the username. So you could add conditional logic based on the login-name that then points to a slug that is derivative of their login name. Put something together in a Gist with inline comments about the user slug and we can go from there.

      1. RevConcept says:

        I thought of that, but didn’t want to restrict my clients when naming groups etc. For example, they have clients with similar group names and I thought this could pose an issue. Also, when they are setting up their pages, I don’t want to have to give them naming conventions for those either. We aren’t under contract for this step of the project yet (they are adding features)…but I’ll post a gist when we get underway.

      2. Matt Cromwell says:

        Actually… a good idea would be to attach a field to the user account called "User Slug" and that is automatically entered when they create the account based on their username. But it can be modified. Then in the redirect all you’d do is reference that metadata as the redirect url. I kinda like that idea.

      3. RevConcept says:

        I was just thinking – what if I have WP auto create a page on this action: groups_created_group. So, when a new group is created a page will be setup with my custom URL structure (based on their group name) and the correct template, page permissions etc. will be ready out of the box. In my head that seems pretty easy, ha.

  3. how force user to login or register before checkout process

Leave a Reply

Your email address will not be published. Required fields are marked *