• Resolved aayaffe

    (@aayaffe)


    I used Data Publisher to create a simple table.
    The table is then inserted into a WP page using the shortcode.
    The page and table are correctly visible to Admin user but for other users or users not logged in I get the following error:

    DataTables warning: table id=e66_waypointracing1 – Invalid JSON response. For more information about this error, please see https://datatables.net/tn/1

    and no data is shown.

    • This topic was modified 3 years, 2 months ago by aayaffe.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @aayaffe,

    It looks like you are blocking the data request. When you open the inspector and activate Network tab, you’ll see the admin-ajax.php request. That request should return the table data. Instead it returns: “Failed to load response data. No content available because this request was redirected”.

    Are you using a redirection plugin? Or a security tool that blocks all ajax request? Can you please check?

    Thanks,
    Peter

    Thread Starter aayaffe

    (@aayaffe)

    I went over my plugin list and could find a plugin that might have blocked or redirected.

    Furthermore when connected as an admin the page works as expected so I am not sure redirection is the issue.

    Is there any other way I can check?

    Thread Starter aayaffe

    (@aayaffe)

    Found something which definitely explains the issue (because the page works well for role1 and role2, and removing the code fixes the issue). I am not sure why is that causing the issue:

    // Redirect subscriber accounts out of admin and onto homepage
    add_action('admin_init', 'redirectSubsToFrontend');
    
    function redirectSubsToFrontend()
    {
      $ourCurrentUser = wp_get_current_user();
    
      if (!(in_array('role1',$ourCurrentUser->roles) || in_array('role2',$ourCurrentUser->roles))) {
        wp_redirect(site_url('/'));
        exit;
      }
    }
    • This reply was modified 3 years, 2 months ago by aayaffe.
    • This reply was modified 3 years, 2 months ago by aayaffe.
    • This reply was modified 3 years, 2 months ago by aayaffe.
    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Good you fixed the issue! ??

    I have no idea what the purposes of this code is, but wp_get_current_user() will always return an empty user object for anonymous users which causes “!(in_array(‘role1’,$ourCurrentUser->roles)” to return true. The redirect will always be executed for anonymous users. Maybe you can fine tune it a little…?

    Thanks for reporting back ??
    Peter

    Thread Starter aayaffe

    (@aayaffe)

    I know why the code is there, I am just not sure why it affected the the plugin in that manner.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Published data only visible to admin’ is closed to new replies.