Notifications
Clear all

[Solved] Subscribe to user don't work if user role is Subscriber

5 Posts
2 Users
1 Reactions
2,733 Views
(@kingstakh)
Active Member
Joined: 6 years ago
Posts: 12
Topic starter  

Have some issue, all user have role 'Subscriber' and when try subscribe to user have error:

SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at Function.n.parseJSON (jquery.js?ver=1.12.4:4)
at Function.a.parseJSON (jquery-migrate.min.js?ver=1.4.1:2)
at Object.<anonymous> (wpdiscuz.js?ver=5.1.5:1344)
at i (jquery.js?ver=1.12.4:2)
at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
at y (jquery.js?ver=1.12.4:4)
at XMLHttpRequest.c (jquery.js?ver=1.12.4:4)

If user role is Contributor/Author/Editor/Administrator all is ok

c99a4bf3 cea4 4545 9943 0ccc1952c969
This topic was modified 6 years ago by kingstakh

   
Quote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6149
 

Hi kingstakh,

Please check does your current active theme contains wp_redirect function? If so, please comment that part and check again. 

I guess this is a similar issue, as described in this post.

https://gvectors.com/forum/how-to-and-troubleshooting/problem-with-user-roles/#post-9302


   
ReplyQuote
(@kingstakh)
Active Member
Joined: 6 years ago
Posts: 12

   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6149
 

I'm sorry, the topic is private. 

Please confirm whether you have found the wp_redirect function in the current active theme?

In that topic, there is a similar issue. In the current active theme, there was the following function:

add_action('admin_init', 'disable_dashboard');

function disable_dashboard() {
   if (current_user_can('subscriber') && is_admin()) {
    $current_user = wp_get_current_user();
       wp_redirect('/author/'.$current_user->user_login.'');
       exit;
   }
}

that was changed to the following one and it started to work correctly.

add_action('admin_init', 'disable_dashboard');

function disable_dashboard() {
   if (current_user_can('subscriber') && (is_admin() && defined('DOING_AJAX') && !DOING_AJAX)) {
    $current_user = wp_get_current_user();
       wp_redirect('/author/'.$current_user->user_login.'');
       exit;
   }
}

   
kingstakh reacted
ReplyQuote
(@kingstakh)
Active Member
Joined: 6 years ago
Posts: 12
Topic starter  

Excellent! I have function with disable dashboard to, now is all ok! Thank you!


   
ReplyQuote
Share:
Scroll to top