AI Assistant
Notifications
Clear all

[Closed] Attachment uploads error for non admin members

3 Posts
1 Users
1 Reactions
1,310 Views
Posts: 3
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@havenwebmanagement)
Active Member
Joined: 3 years ago
[#12042]
Error SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON
 
This is the error when trying to upload files. Works okay for Admin but all other members unable to upload.

 

error

 


2 Replies
Posts: 3
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@havenwebmanagement)
Active Member
Joined: 3 years ago

Found the issue, this code was running in snippits:

function restrict_dashboard_access() {
if (is_user_logged_in()) {
$current_user = wp_get_current_user();
$user_roles = $current_user->roles;
if (!in_array('administrator', $user_roles)) {
wp_redirect(home_url());
exit;
}
}
}
add_action('admin_init', 'restrict_dashboard_access');

 

This was stopping the upload feature.


Posts: 3
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@havenwebmanagement)
Active Member
Joined: 3 years ago

To fix add an additional check to ensure that the redirection is only performed if it's an admin page and not an AJAX request. This allows the attachment uploads in wpForo to proceed.


Share:
Scroll to top