Select_advanced not loading

Support MB Frontend Submission Select_advanced not loadingResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #45301
    YasmineYasmine
    Participant

    I am getting "The results could not be loaded" on a taxonomy_advanced select2 field when using a limited user role account (works on administrator):

    [
    'name'       => __( 'Specific methods used', 'your-text-domain' ),
    'id'         => $prefix . 'academicresearch_methods',
    'type'       => 'taxonomy_advanced',
    'taxonomy'   => ['research-methods'],
    'field_type' => 'select_advanced',
    'placeholder' => __( 'Select a method..', 'your-text-domain' ),
    'multiple'   => true,
    'class' => 'ref_p13-4 ref-label ref-group',
    'columns'    => 12,
    'ajax'     => true,
    'js_options' => [
    'minimumInputLength' => 1,
    ],
    ],

    When I give my limited-role user all the roles, then it suddenly works again. Is there a user role that is needed for the options to load in a select2 field?

    #45303
    YasmineYasmine
    Participant

    I think it is something to do with my own settings. I disabled code in my functions.php and working again, sorry for the unneeded ticket

    #45304
    YasmineYasmine
    Participant

    The problematic code is:

    /* Restrict dashboard access to non admin */
    add_action('admin_init', 'restrict_dashboard_access');
    function restrict_dashboard_access() {
        if (!current_user_can('manage_options')) {
            wp_safe_redirect(home_url());
            exit;
        }
    }

    So dashboard access is needed to see the advanced search field and favourite posts (same issue as my other ticket: https://support.metabox.io/topic/user-permissions/ )

    With manage_options granted, it works.

    I want to limit backend access, but I want this to work. What can I do?

    #45306
    YasmineYasmine
    Participant

    You add a:

    ` if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    return;
    }`

    Ok ignore me

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