Hi @bobjgarrett,
Thanks for reaching out! I’m sorry to hear about the issue with submitting the form.
Could you please share your extra code when you have a chance? That will help me try to reproduce the issue and provide more information.
Thanks, and please let me know!
This is the code…
//Extra testcode to restrict access
// Restrict WordPress admin panel access to specific user roles
function wp_dudecom_restrict_admin_access() {
// Check if the current user is trying to access the admin panel
if (is_admin()) {
// Get the current user's role
$user = wp_get_current_user();
$allowed_roles = array('administrator', 'editor'); // Define roles that are allowed access
// Check if the user has one of the allowed roles
if (!array_intersect($allowed_roles, $user->roles)) {
// Redirect users without the allowed roles to the homepage
wp_redirect(home_url());
exit;
}
}
}
add_action('admin_init', 'wp_dudecom_restrict_admin_access');
// Ensure that users without access cannot see the admin bar
function wp_dudecom_hide_admin_bar_for_non_admins() {
// Get the current user's role
$user = wp_get_current_user();
$allowed_roles = array('administrator', 'editor'); // Define roles that are allowed to see the admin bar
// Hide the admin bar for users without the allowed roles
if (!array_intersect($allowed_roles, $user->roles)) {
add_filter('show_admin_bar', '__return_false');
}
}
add_action('after_setup_theme', 'wp_dudecom_hide_admin_bar_for_non_admins');
?>
Hi @bobjgarrett,
Thanks for sharing the code!
I tried it with the WPCode Lite plugin, as well as with the WPForms Lite, WP Mail SMTP Lite, and Twenty Twenty-Five themes on my test site. I had no issues submitting my forms.
The problem may be a conflict with another plugin or your theme. When you get the chance, could you please try using the steps in WPBeginner’s detailed guide on troubleshooting WordPress to see if it helps resolve the issue?
Thanks!
Hi @bobjgarrett,
We haven’t heard back from you in a few days, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.
Thanks!