Users Permissions

9.05K viewsCorepermission user
0

I have a user structure under the name “Customer” integrated with WooCommerce.

But only users “AnPress Participants” can ask and respoder the plugin. It is possible to change this?

0

Allright, I found a way to make it work but I’m pretty sure it’s a  little hack around the whole thing! but just wanted to let you know how I did it for future reference;

Change this line:

 

$roles = array(editor, contributor, author, ap_participant, ap_moderator, subscriber);

and add any role you want (in your and my case, customer)
to the class-roles-cap.php

it’ll look like this:

$roles = array(editor, contributor, author, ap_participant, ap_moderator, subscriber‘, ‘customer’);

when you did that, click save

then deactivate the plugin, and activate it again.
apparently the roles get called on activation so that fixes it!

the only problem is that you have to do this manually after every update I’m afraid. Hope this helps for you as well!

Cheers,

Robin

Robin, thanks for the solution. I have a fix for this too, I will allow basic capabilities of AnsPress to every role. So we dont need to update every role and it will ensure 3rd party compatibility.

Ah okay, is that already out or will it be in the next release? and no problem! this woks temporary at least! thanks for your help!

Currently working or notification system, and after that will add fix for user roles. 🙂

Hi, I changed file class-roles-cap.php, but did not work for me. 🙁

Please give me some days to work on this.

hmm that’s weird!it worked for me! if you need help feel free to shoot me an email at [email protected] I’ll see if I can help you some how!

0

What is you AnsPress version ? and what is current user role ?

Hello,

AnsPress 2.2.0.2 and users roler is editor.

I will check this and update you soon.

any answer on this? got the same problem! I want my users (subscribers) be able to answer and post questions! all I get now is a “You dont have permission to ask question.” error!

AnsPresss add all default capabilities to WP user roles. I think you have enabled some options in AnsPress permission tab. You can check our source code here: https://github.com/anspress/anspress/blob/master/includes/class-roles-cap.php

Hi Rahul, I just noticed that all users created get the Customer role by WooCommerce, so I guess that’s why they can not answer or post questions.. I’m not really a huge developer myself but is it safe to assume that when I pick this line

“$roles = array(‘editor‘, ‘contributor‘, ‘author‘, ‘ap_participant‘, ‘ap_moderator‘, ‘subscriber‘);”

and change that to:

“$roles = array(‘editor‘, ‘contributor‘, ‘author‘, ‘ap_participant‘, ‘ap_moderator‘, ‘subscriber‘, ‘customer’);

it should work right?

Ah… yeah no I just tried that, that doesn’t work! pretty sure my settings are right because I have checked them 10 times now.. it works when I change the role to subscriber, but that’s not what I want! I want the role to remain Customer!

any help would be greatly appreciate it 🙂

Sorry, last comment, I just found a work around! posted in a new answer here so Wagner_willian sees it as well! the key is adding the role in the code, deactivate the plugin and re-activate it. not the best way to make it work, but it works! if you happen to have a small script for this that I can put in my functions.php that would be great!