Login for Author ends up on frontend instead of backend

Hi guys,

I recently installed Membership2 Pro. A really cool plugin and I'm using it to manage internal pages for several memberships.
But now my authors for the website have some problems:
if they Logon via wp-admin URL, they get back to the "my account" seite on the frontend.
To enter the backend,
- they need to enter the WP-Admin URL again and the top bar is missing
- I need to deactivate the setting disable admin-toolbar for non-admins
(but in this case every logged in user sees that bar).

So, on the frontend I can get a work-around by adding a author-membership and putting a menu-item in the menu linking to the backend for authors. But in the backend they still don't have the top-bar... so - as unexperienced they are - they never find the way back :wink:.

Long story short:
what I need is the ability, that a author logging in through wp-admin still lands in the backend and gets his admin-bar in the backend and the frontend.
All other members - who has memberships (authors don't have any memberships usually) needs to end up on the frontend without any admin bar.

Is there a simple way to achieve this?
Thanks in Advance :slight_smile:

Christoph

  • Christoph

    Hi Nastia,

    I'm fine thanks :wink:
    No, not exactly. I try to describe it better :wink:
    Usually, every user that logs in into the backend (via wp-admin) ends up in the backend.
    With the installed Membership2 Pro, every user (except admins)
    - ends up on the front-page (account-page)
    - without toolbar.

    On my site, I have to differ between
    - "users with memberships" that wanna use the internal part of the website, but not the backend. For them, that behaviour is perfectly well: they may log in on the frontend and land on their account page and they have no admin bar (as featured with Membership2).
    - "authors" that usually only use the backend to create/edit content. They have no memberships and no admin rights, but only editing rights in the backend for a few pages.

    For my "authors" the behaviour of the membershipPro Plugin does not fit the needs, because it overrides the global stuff. So when trying to access the backend via wp-admin they end up on the front page with no admin bar - like the "user with memberships".

    If I activate the "disable admin-toolbar for non-admins" option in MembershipPro settings, I get back the admin bar for my authors. But they still end up in the frontend instead of the backend. And the "users with memberships" now get the admin bar as well - and they shouldn't.

    Do you understand my problem here? :smiley:
    Kind Regards,
    Christoph

  • Sajid

    Hi @Christoph,

    Hope you are doing good today :slight_smile:

    To redirect author users to wp-admin page after login. Try adding following code in functions.php file of your child theme of use mu-plugin.

    add_filter('ms_controller_frontend_login_redirect', 'wpmudev_ms_redirect_filter', 10, 4);
    function wpmudev_ms_redirect_filter ( $redirect_to,	$request, $user, $this ) {
    
        if ( in_array( 'author', $user->roles )  ) {
        	$redirect_to = admin_url();
        }
    
        return $redirect_to;
    }

    Hope that helps! If you still need assistance, please don't hesitate to ask.

    Take care and have a nice day :slight_smile:

    Kind Regards,
    Sajid J

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.