aredon
Forum Replies Created
-
At the very least maybe consider making the user aware that changing their settings on the subscribe2 page in the admin panel will have no effect since they are network-level users?
Edit: Seems that I got this working. ?? Thanks!
For posterity I’ll note here that I followed This post about setting up custom user capabilities. Basically my function above will enable someone to use the members plugin with subscribe2 to control mailing lists based on user capabilities.
Thanks for the hooks! I take it that the $recipients list contains only a list of emails and not additional user information? I suppose I can just use get_user_by to pull their WP_User object if that’s the case.
With those hooks I imagine something like this will work? I think I’m relatively confident in this solution.
public function enforce_caps_s2($emails,$post_id){ //prepare a new list $list = array(); //pull and check the post type to make sure we're modifying the list $post_type = get_post_type($post_id); if($post_type == 'reimbursement'){ foreach($emails as $email){ //grab the user id $user_id = email_exists($email); //check user existence if(is_numeric($user_id) && isset($user_id)){ //check permission if(user_can($user_id,'read_reimbursements')){ //add to list $list[] = $email; } } } } return $list; }
As a suggestion for the future perhaps some testing can be done on performance issues when storing user capabilities as well. ??
Edit: code update
Unfortunately they will be logging into wordpress as the client I’m working for will be using wordpress as an overall content management system. The user’s have some data that has to be tracked and attached to a user account (they are members of an organization). Also as a result of this CMS nature, some of the content will be user-side and some of it will be management-side. Which therein lies the problem of trying to control content with Subscribed2. This is only the first custom post type of many to come, and I need to be able to control who sees what.
I would love it if the registered/public route was an option, but I’m afraid it won’t be for this project. I understand if Subscribed2 isn’t meant for this sort of thing, but if there’s a hook somewhere I don’t know about or a hack I can implement do let me know. I just didn’t want to be writing separate (and custom) email hooks for each post type. It would get cumbersome and not very user friendly.
Hmm I find it a little difficult to imagine the load would be worse than sending a bunch of extra emails, but I could be wrong on that. I haven’t checked, but I’m guessing that the plugin uses get_userdata() for each user on the list in order to have access to their emails. If that’s the case why couldn’t it grab caps from the WP_User object as well? For simplicity here perhaps a capability could be passed with the s2_post_types hook when adding a new post type.
I’m currently running everything on a development server, but for this specific case there will be one user with access to these posts, and about 5,000 or so registered users who will not have access. It’s an internal record-keeping thing, and the users shouldn’t emailed about it. The admin just wants to be alerted when a new one is posted.
I suppose I could just lock out access to the plugin to all non-admin users, but then I would lose it’s functionality for other posts as well… unless I do something gross like create a copy of the plugin and name it something else.
The use of that if statement was meant to prevent the user from subscribing to that category or post on the front-end of Subcribed2. (i.e. hide the checkbox) I realize that it will not change the behavior of the emailer itself. I was at a loss as to why Subscribed2 was ignoring the user’s ability to actually view the post at all.
So you’re saying that there is no way to prevent Subscribed2 from emailing people who otherwise could not view the post in any way? The other users will receive a “not found” if they go through the wordpress url, and yet subscribed2 will send them the information they can’t get any other way.
Basically only the administrator should receive emails for the post type that only he or she can access normally. Doesn’t it make sense to evaluate user capabilities on a case by case basis? Is there some way that I can force this behavior?
The front end is a custom template, yes. It’s also a custom query pulling from the connections databases. The front end is working perfectly. It is unfortunately the connections plugin on the backend that is the issue currently.
I will copy this reply on the support forums, but I’m putting it here for reference.
Forum: Plugins
In reply to: [Admin Columns] cpac_get_column_value_custom_field won't fireI suppose I’ll have to revert to an old version as well. I appreciate the version number dotkev.
Forum: Plugins
In reply to: [Admin Columns] cpac_get_column_value_custom_field won't fireAny word on this?