User Registration: Hiding WP User Bar?

I’m a newbie with Gravity Forms and am starting to configure the User Registration add-in to suite my needs… so there will be a lot of questions coming soon :slightly_smiling_face:

Goal

The web site I’m working on is for an adventure camp for special needs children and adults. What I’m aiming to do is allow volunteers and parents of the camp attendees to be able to register on the web site and then complete camp registration forms. As such, these registered users aren’t really WordPress users, they’re just users of my site that I need to be able to identify to be able to link and show their registration forms when they login.

Issue

I got the user registration login working w/o issue. I have the defaulted a newly registered user to have a role of “Subscriber” for now, as that is the least-privilege role that exists. Because the user registration component actually creates the newly registered user as a “subscriber” on my site, when I login with a newly registered account, I’m seeing the WP administration bar (or whatever it’s called) on the top of the web site. For this use case, users that register on my site should not see nor be able to access the WordPress settings area.

Hence my question is, how do I hide and disable access to the WordPress settings area for users that register to my site via the User Registration add-in? Is there a way to create a custom role that doesn’t allow access to the WP admin pages?

Registered users will only be able to see pages and forms that I decide and nothing more.

This image shows the WP user bar that should not be visible or accessible to this registered user.

This is the solution I’m currently using. This doesn’t restrict them completely from accessing the wp-admin, but does hide the admin bar and admin menu from unprivileged roles. In this way, I’m still able to allow them to access their profile for configuring 2FA or other settings that aren’t easily ported to the front-end. If you want to completely wall off the wp-admin from them, you should be able to find a plugin listed in the WP directory.

// Hide admin bar for subscribers
add_action( 'after_setup_theme', function () {

  if ( ! current_user_can( 'edit_posts' ) && ! is_admin() ) {
    show_admin_bar( false );
  }

} );


// Hide admin menu for subscribers
add_action(  'admin_print_scripts', function () {

  if ( ! current_user_can( 'edit_posts' ) ) : ?>
    <script type="text/javascript">jQuery(document).ready(function($) {
      $('#adminmenumain').remove();
    });</script>
  <?php endif;

} );
1 Like

:goat:

1 Like

I don’t have FTP access to the site to add a script, so I had to accomplish what I wanted via the following plug-ins:

  • Remove Dashboard Access - Allows for disabling dashboard access to non-admins and editors.
  • Hide Admin Bar From Front End - Allows for completely hiding the admin bar from selected roles.
2 Likes