• Resolved bobjgarrett

    (@bobjgarrett)


    I have a strange situation where what were working forms are not now being submitted. This is occurring when I add some extra code to functions.php in the theme. The intention of the code is to restrict access to the toolbar/dashboard for some types of users so I cannot see how it might affect form submission. I made a test site with the same theme and your plugin and it works correctly.

    So, it might be some interelationship with another plugin but that seems less likely given the forms work until that extra code is added.

    I am struggling to understand and wonder if you might have any suggestions, or whether there are any tests you can suggest? Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Ralden Souza

    (@rsouzaam)

    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!

    Thread Starter bobjgarrett

    (@bobjgarrett)

    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');
    ?>
    Plugin Support Ralden Souza

    (@rsouzaam)

    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!

    Plugin Support Ralden Souza

    (@rsouzaam)

    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!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Forms not submitted’ is closed to new replies.