Support » Fixing WordPress » I get an “Item doesn’t exist” error after logging in

  • Before I changed the way my login screen looked by using the Colorlib Login Customizer plugin, the old login screen used to look like the picture at https://images.app.goo.gl/aYZMHzA1Ux1Pa5gs9. Now, I’m trying to figure out if a problem is from the old login method, or the way I changed it by using the Colorlib Login Customizer. My problem is that, when I use the login screen that I changed, it logs me in, but takes me to a page that gives me the message “You attempted to edit an item that doesn’t exist. Perhaps it was deleted?” (If other users get that message, they might not know that they were logged in.) Sometimes, when I log in as a user that isn’t an administrator, I get another error message that sounds to me like it is trying to take me to a screen that only administrators can use, because it says that I need a higher level of permission. If it is remembering where I was before I logged out, is there a way to stop it from remembering? Can it remember where I was before I logged out, even if I was an administrator before I logged out, and I’m not trying to log in as an administrator? Could this be a problem with the form that I use to log out? Any help would be appreciated.

    Also, sometimes when I log out it (1) takes me to the page that I made with the Colorlib Login Customizer, and at other times it (2) brings me to my home page (where there is a different login form). How does it decide which of those two to do? Can I tell it which of those two to do?

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    I can only speak about default login form behavior, but the mechanism is used often enough I’d expect login alternatives to enable the same mechanism. Where you are taken after login is controlled by the “redirect_to” parameter. It’s usually passed as an URL query string with the login request. This allows you to return to the page you were on when you were prompted to login.

    The parameter is filterable, so code can alter the destination, overriding the passed query string. If an admin page is cached, it’s possible to revisit the page even when logged out. Admin pages normally are not cached to prevent this possibility, but abnormal situations could exist.

    If you get an items doesn’t exist message for something you’re sure exists, it’s likely the query to fetch the item was inadvertently corrupted somehow so that the query failed to return the expected result. You can try to narrow down the cause by selectively deactivating plugins and switching themes.

    Thread Starter jason4locations

    (@jason975)

    Thank you, bcworkz.

    I think I understood some of what you wrote, but not all of it.

    To help users who aren’t administrators, and who are trying to log in and go right to the home page, can I make use of the “redirect_to” parameter by making changes in Dashboard > Settings > Permalinks > Common/Optional settings? What is the easiest way to make use of the “redirect_to” parameter?

    It seems like the item would exist for a user after they log in if they were the user who just logged out, because they got to the item already (before they logged in again). But, I can’t test that idea (which involves logging in as the user who just logged out), because sometimes (if not all the time) I don’t get taken to the Colorlib Login Customizer page, after I log out.

    Can I make the item the home page, and the home page item exist for all users who just logged in?

    (I might be repeating what I said before, because I didn’t understand everything that you said. Maybe someone can explain, or tell me where I can go to learn more so I can understand.) When the user who logged in is different from the user who logged out right before them, will an item not exist for the user (who logged in last, and is trying to go right to the home page) because the user (who logged out right before them) went to that item last, and the user (who logged in last) didn’t go to that item yet? In other words, when the users are different, it is the user who logged out, and not the user who logged in, who gets to decide which item it is. Is that right? Is it possible that this is the case, and not that the query was corrupted?

    Thread Starter jason4locations

    (@jason975)

    I made it sound like users can get to other users’ items, but maybe that isn’t always the case.

    Moderator bcworkz

    (@bcworkz)

    Who can see what can be pretty variable, depending on how content was created and what plugins do to manage visibility. All users should be able to see all public content, logged in or not. Logged in users can additionally see their own private content, but not other’s; unless they have admin capability to see everything. They’ll also see whatever backend features their user role allows them to see. Subscribers only really see their own profile and little else. Admins of course see everything.

    What logged in users can see is cookie based. If the login auth cookie exists, the user can see all that the cookie and their related role enables them to see. When one logs out, the auth cookie is destroyed. Then only public content is visible. Now, if one viewed private content when they were logged in, then they logged out, but left their browser open, the private content could be saved in the browser cache and still be accessible without the auth cookie. Closing the browser after logging out will eliminate that possibility.

    Sorry, I misspoke earlier. “redirect_to” is the URL query string name as I said, but the related filter is not also “redirect_to”, it’s “login_redirect”. Serves me right for relying upon memory.

    If you wish all users to be returned to the home page after logging in, regardless of where they were before, some simple custom code would hook the “login_redirect” filter and return the home page URL. The code could be modified to not do so for admin users, or take them to a different place like the admin dashboard (the normal default after login for all users). Custom code like this is easiest to add by creating a simple custom plugin. This plugin can also hold most other custom code you might want to add, now or in the future.
    https://developer.wordpress.org/reference/hooks/login_redirect/
    https://developer.wordpress.org/plugins/plugin-basics/

    Thread Starter jason4locations

    (@jason975)

    Thank you, bcworkz, for all the work you put into your last post.

    I still have some homework to do, so I can learn about cookies and caches.

    In the meantime, would you please confirm that I only need to worry if the user who logged in is the last user to log out, and I don’t need to worry if a different user was the last user to log out? Or, do I need to worry about that too?

    Also, thanks for showing confidence in my ability to make custom code.

    Still, if there are very simple plugins (that are already made) that can do what you have been describing, how can I compare those plugins (which are already made) with each other?

    Moderator bcworkz

    (@bcworkz)

    Assuming non-buggy code, the only way an user could see the other’s private content after they had logged out is if the browser they used remained open and another user used the very same browser instance to view cached content. Non-buggy code would always verify the auth cookie before serving private content. No auth cookie, no private content.

    There appear to be a number of login redirect plugins:
    https://wordpress.org/plugins/search/login+redirect/

    Try out a few and see if they will meet your needs. I would be inclined to give preference to one with a larger installed base and whose author appears to be responsive to support requests and handles critical reviews in a calm, professional manner. But I’d possibly consider a little used, unsupported plugin if it met my needs better than any other.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.