1

I'm creating a dashboard app and decided to use WordPress since it has a dashboard that has 100% of the functionality I need out of the box. The dashboard itself has a few dashboard widgets users can customize.

What I need is to grant logged out users access the dashboard. I plan on storing their dashboard configurations to localStorage and just transfer that data to their profile once they create an account. The idea is that more people will use the app since creating an account is the biggest barrier and for what my app does, is unnecessary anyways unless you need longterm storage.

Basically, I need people to visit mysite.com and start using my app right away without needing to register first.

My workaround right now is to signon visitors into a guest account and redirect them to the dashboard. My index.php looks like this:

<?php
/**
 * The dashboard IS our app, so we log them in with a guest account
 */
if (!is_user_logged_in()) {
    wp_signon([
        'user_login' => 'guest',
        'user_password' => 'guest',
        'remember' => true
    ]);
}
wp_redirect(admin_url());
exit();

I already have logic in place to disable admin pages, hide widgets, and replace the "Howdy, 'Guest'" menu with a login button that logs them out of the guest account and takes them to the built in login/register page. I'd like to remove all this complexity by lowering the permissions/capabilities required to see the dashboard if possible.

2
  • What complexity are you trying to get rid of? It seems you already have what you want by automatically signing in users to your app. I think I'm missing what you want done differently!
    – bynicolas
    Commented Sep 5, 2016 at 3:44
  • Basically I shouldn't need to sign users in in order for them to see the dashboard. In wp-includes/pluggable.php, the function auth_redirect seems to be what handles kicking users out of the dashboard if not logged in. I can't seem to find a way to disable that so that they don't need to be logged in to see the dashboard.
    – Oz Ramos
    Commented Sep 5, 2016 at 5:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.