WordPress has some lovely features for storing revisions, editor approval of content, etc.
I'd like to expand on them by creating the concept of a user group/organisation.
I want:
to be able to attach posts to an organisation
to be able to attach users to an organisation (and ideally make it so that users can invite other users to their same org)
users can only make changes to posts in the same org as them, everything else is read only.
I can do the first two with a custom post type and an Advanced Custom Fields post object field, but I'm stumbling on the last one and would appreciate some pointers.
I imagine I would need to create a custom role with add_role(), but I'm not sure what capabilities it should have.
I imagine I'll need to override a hook somewhere to check if the thing the user is trying to edit is in their org.
Only relevant code so far is:
register_post_type("organisation");
First, on WordPress, the default user system is: admin can do everything, editors can edit every post, authors can only edit their posts.
There are some plugins like https://es.wordpress.org/plugins/user-role-editor/ that may be useful for your needs. Have a look at that!
Related
Is there a way in which I can disable/hide specific fields from the "page form" in the back-end? I have currently test two plugins but none of them meet the requirement that I have, like for example this plugin "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
I'm sorry that the options are in spanish but the capabilities options are for example: "edit pages", "edit other people's pages", "publish pages", "delete pages"... What I want is to hide certain sections to the "editor" user role from the page form:
Is this even possible?, and if not, what alternatives do I have?, the thing is that I'm afraid that whoever is in charge of editing will end up messing up with the pages...
Use Adminimize plugin It will resolve problem easily.
This plugin changes the administration back-end and gives you the power to assign rights on certain parts.
In most cases, the plugin "Adminimize" that Tech Sourav mentioned will work just fine, but since this page I'm working with is using some annoying custom content editor and other theme tools, the workaround that I ended up doing was:
Create a custom post type with the "Custom Post Type UI" plugin.
In this case I will only and always have 3 pages that have this "modifiable" price field, so once the custom post type is added I added 3 entries to this custom post type (here I will show you just one).
I'm also using the "advanced custom fields pro" plugin in order to create this price field into my entries.
When the custom field has been created there's this option inside the same previous form that allows me to show that specific field just created into specific post types entries, so I made up the rules in order to show this field in the created custom post type entries:
In this example I'm just showing you the rule for one entry, in order to make it appear on the other 2 entries, I would just click in the "agregar grupo de reglas" and select one by one.
Once this custom field and rules are configured correctly, I should see now the custom field "precio" inside my specified entries form:
After saving the entry with the updated custom field value, I will now check the post id and save it for later (we're going to need it):
According to the documentation of Advanced Custom Fields plugin I can show the saved value of certain input within certain post with the shortcode: [acf field="{$field_name}" post_id="{$post_id}"], in this case I will change the values to: [acf field="precio" post_id="1372"] and paste the code into the section of the page that I will show this:
The builder that this page is using has an element called "code block" but you can use it in the equivalent element that allows you to paste code from your theme.
After saving the changes, now the only thing that I have left is to restrict the ability to edit pages to a user with the "editor" role, for this I will use the plugin that I mentioned before in my question called "User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress":
As you can see, I will not let editor users to mess up with the pages post types, so with this, they will only be able to edit the custom post type that I created, which even if they write something inside the content of that custom post type entry, the website won't be affected at all. This may be a little bit hacky but it works...
I am very experienced with Wordpress development, however, I have been asked to do something that I haven't before and my initial thoughts of setting and removing capabilities from individual users isn't working out too well...so I thought I would get a second opinion.
The situation is as follows: On the user edit profile screen in the admin area I have added some additional check boxes. The site has a few different custom post types, so there is a checkbox for each post type for User Can Moderate [Post Type] .
Each user on the site has the Author role, but what I want to do is manage the user capabilities so if say a user named John has the checkbox for Moderate Test Post Type checked they should be able to edit, publish and delete other people's posts in that particular post type. They should also be able to create , edit, publish and delete their own in that post type unless another checkbox is unchecked saying they can't create their own content.
Now I assumed that when saving the options I could bring in a WP_User object and add_cap and remove_cap on the custom post type. It works to an extent but it seems to trip up on itself and I'm not sure what I am doing wrong.
So for example, if the user is NOT able to create their own content but CAN edit, publish and delete other peoples content I would have thought removing the edit_posts, create_posts and delete_posts would do that and adding capabilities (replacing _posts with the post type) for edit_others_posts, publish_others_posts and delete_others_posts would do it, but it doesn't! If I remove their ability to create their own content I can't seem to get them to be able to edit other peoples content.
Has anyone any idea how to solve this?
I always find really difficult to work with users in Wordpress. So here's the question.
Let's say I want to use Wordpress to build a website with users and I don't want to use standard Wordpress users. I want my users, let's call them siteusers, to have multiple custom fields. I want them to have relationship with custom post types in my site.
For instance let's say I want to build a Spotify clone. I want my users to register, login, but also to create playlists, add songs to playlists, wishlists, etc. I want to have a logic behind this, and i want users to be able to download only songs they have access to.
My idea is to create a custom post type called "siteusers" and add custom fields to them and make a new frontend register/login/lostpassword/my account page/ machanism, different from the standard WP one. I would have to build an authentication method like i would on a rails application without devise.
Could it work, or are there wordpress limitations I am not seeing? Are anyone aware of any similar solution/plugin/tutorial that could save me some work?
i manage my company website which runs WordPress. There are several chapters across the USA. I have pages setup for them so that people can view our chapters content. I was wondering, instead of them emailing me the changes they want. Is there a way where i can allow the users to only be able to edit a single page, without giving them access to the entire WordPress admin page/ website.
I would be willing to pay for a commercial plug if this option exists. Thanks for reading this.
There are Various Free / Paid Solution will be available for this based on your Model You can Choose any one of the following or there could be many other ways to get this done these are some of the way
You Can make them Editor and The Owner of the Chapter which they blong so in this way they will not have any rights to Edit other Chapters they will be only able to edit the Chapters which they own.To restrict other access in this case you can use plugin like User Role Editor and many other available at Wordpress repo.
You can also customize plugin like WP User Frontend to achieve the front end edit possible.
A Complete Custom Solution where use need not to login they simply submit the Changes which will be logged as article draft and you can later review and approve.
i think there will be much more way but it will be completely based on your applications nature so hope this helps to you.
In Drupal I wish to create a content type as a bio for a user. When you click on a a user name on the site it takes you to there bio. An example I have found online is below.
This article has the authors name Jeff Robbins. Jeff Robbins name links to his profile. How would you go about doing something similar? It does not seem be using the default profile module.
I would ideally only like this to happen for users in a certain group. For other users I wish just for there name to display but no link. Any pointers about how I would do this?
You've already got the core/programming route explained, so I thought I'd chime in with a few signposts on the install-a-module route. As always, with modules there is a bloated but supported solution and guidance on DIY.
Content Profile
Content Profile is a module specifically targeted at supported a User Biography as a node.
Here is an article describing how to add author biographies to nodes using Content Profile.
Author Pane
This module pulls information from the profile with an eye toward creating the sort of author information you would find to the left of a messageboard post.
Permissions
There are a couple modules that add finer control to the Profile permissions mechanism. There may be more, but these jumped out while I was looking for Content Profile.
Profile Role
Profile Permission
The node creator is stored in the node table (column UID), you could write something in a nodeapi hook to take that insert it as a field which can then be themed however you want. You could even in this hook put some logic to make the name a link or not depending on the roll.
You may want to look at the profile module, as this will allow you to set up a bio much more easily.
You can like Jeremy suggests do something like using hook_nodeapi(), but that seems like a bit overkill. I would instead use the template_preprocess_node() function. You could put this into a module or a theme. With it you can change the variable for $submitted, which holds the info for the author, date published etc. You can format it like you want, and keep the date and all that, and just instead make a different link on the user.
You could make it point anywhere really, so that the user is directed to a custom page that holds info on that user. It could a node on itself that you can setup with CCK ect, or you can use one of the profile modules that let your users customize their profiles, whatever works best for you.