PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Logged In User Post Submission Advice Needed (specific categories based on user)

  1. awarner20

    Hi all,

    I'm looking for advice on how to make the following process flow work within Gravity Forms. I believe most is handled by GF by default with the exception of the specific categories available per user.

    Users will be registered for the site using either the GF User Registration OR using Wishlist Member plugin.

    Each user is a company and each company will have the ability to create a blog post through GF's Post Fields capability. The user will need to be logged in, in order to submit this form. I understand that there is a setting in GF post fields to allow this and user that user's information as the post author. This is great and will work.

    The part I'm trying to find a solution to is to filter the available post submission categories based on the user who is logged in while submitting the form.

    Use Case:

    1. User 1 is allowed to submit posts but only attach that post to categories A and B.
    2. User 2 is allowed to submit posts but only attach that post to categories C and D.

    Each user should only see the categories available to them when posting (and/or these categories will be set to be attached by default within the GF post fields settings.

    Is it possible to filter available categories in a post field submission form based on the specific user who is logged in when submitting that form?

    My only alternative at this point is to create a separate member level in Wishlist for each user (company) and then create a separate form for each user and place that form behind each user member level. As you might imagine, this is not really an alternative because I would end up creating 100's of member levels (with one user attached) and 100's of individual forms.

    I am looking the above functionality and if it doesn't exist, is this something I can get created programatically with a custom function or a custom GF plugin?

    Posted 12 years ago on Wednesday March 21, 2012 | Permalink
  2. awarner20

    Does anyone have any advice on this?

    Posted 12 years ago on Tuesday March 27, 2012 | Permalink
  3. bradvin

    Hey Adam,

    How do you assign post cetgories to a user? By role? And how do you actually do this linking?

    That is the first problem. Once you can link a user to post categories, then you can quite easily limit the categories that he can create posts for


    Posted 12 years ago on Wednesday March 28, 2012 | Permalink
  4. awarner20

    Hi bradvin, thanks for the reply.

    How do you assign post categories to a user? By role?

    Good question. As I said above, the users will likely register using the GF User Registration Addon OR through the Wishlist Member registration form (so they can be added to a pre-determined member level).

    As the exact registration methods above are still being vetted, perhaps either of the following could be done:
    1. When viewing the Categories list in the backend, an option exists to "Assign User to Category". This allows an admin to select a user (or users) and then "Save" that user to that specific category.

    2. In the user profile page, perhaps an option to "Assign Category for this User" exists. An admin then sees the category list and checkmarks the category (or categories) that user should be assigned to.

    And how do you actually do this linking?

    The admin user process could work like the above, but the programmatic process of doing the actual linking is beyond my knowledge. Other than to suggest perhaps another table in the DB that holds the User IDs and Category IDs that they are assigned to when the above options are saved?

    Then of course comes the limiting of categories based on User in the GF form.


    Posted 12 years ago on Wednesday March 28, 2012 | Permalink
  5. bradvin

    I think it would be best to link the categories to a custom role, rather than a user.

    Then for each category have a way to link to a role. (some admin screen perhaps)

    So when your users are registered, they are assigned roles (which is probably already the case)

    Then displaying the correct categories in the gravity form could be done by creating a custom field, or override the choices assigned to the category dropdown using GF filters:

    add_filter('gform_pre_render' , 'setup_my_form' );
    function setup_my_form( $form ) {
      //loop thru all fields
      foreach($form['fields'] as &$field) {
        //if its a category field
        if ($field['type'] == 'post_category') {
          //get the logged in user
          //get the roles for the user
          //get the categories allowed for those roles
          $field['choices'] = get_category_choices_for_logged_in_user();
      return $form;
    Posted 12 years ago on Wednesday March 28, 2012 | Permalink
  6. awarner20

    OK. I understand what you're suggesting, I think this would streamline the Admin work somewhat by allowing me to use one form based on a user role/category match. Makes sense.

    The manual Admin work will come into play when creating these custom user roles (which I'm not opposed to, I'm just thinking this through out loud here).

    There are a few things I need to consider with custom user roles in regards to Wishlist member levels also. In Wishlist, you can assign any existing user role to a member level. This may put a hitch in the process, here's why...

    As I said above, each user is a company. The GF form needs to filter available categories by user role. So when a user signs up to the site (or is added manually more likely), a custom user role will be created and assigned to that user.
    (for clarity, the custom user role I create should have the same capabilities as the built-in Subscriber role. So really, the only thing different about any newly created user role would be the name. Ex: New User Role--> "Acme"

    Ex: Bob from Acme is added as a user. The "Acme" custom user role is created by Admin and then assigns that user role to Bob. Then, using the suggestion above, the Admin also assigns the "Acme" user role to specific categories(s). This enables the GF category filtering based on user role. Perfect.

    The possible hurdle here is that user must also be attached to a specific Wishlist member level.

    In Wishlist, when a new member is added, they are assigned the "Subscriber" role by default. However, Wishlist also allows you to assign a specific user role to any member level.

    Ex: You have a member level and you want members of that level to have "Editor" rights. You would assign the "Editor" user role to that level so when a new user signs up or is added to that level, they have "Editor" rights instead of the default "Subscriber" level.

    Using the process above, if we created a custom user role, assigned that role to the correct user, then attached that role to specific categories...we would also need to add that user to a specific member level. If the member level does not have a specific user role assigned in Wishlist (other than the default Subscriber level)...then the questions for me to figure out are:

    1. When I add that user to a member level, does their custom user role we added get changed to the default user role that the Wishlist member level uses?
    (I think probably not, but I'll need to test this)

    2. If I'm wrong about the above, then will I need to create a member level for each custom user role and assign that role to that member level?

    In Summation:
    To get this done, I will need to do the following...

    1. Use a plugin to create custom user roles:

    2. Test the WLM user role question above.

    3. Get the User Role-->Category Attachment process figured out:
    This can possibly be handled using the Role Scoper plugin as it has the capability of "Assign restrictions and roles to specific pages, posts or categories"

    4. Get the GF "post submission form category filtering based on user role" plugin developed.


    So, what do you think? Make sense?

    Posted 12 years ago on Friday March 30, 2012 | Permalink
  7. bradvin

    lol that was quite a post :)

    I think that would do it.

    A question : are the categories unique to a user? Or can they be reused btw users?

    Posted 12 years ago on Friday March 30, 2012 | Permalink
  8. awarner20

    Yeah, sorry for the length on that one...had to think it through;)

    They can be reused by other users. So, multiple users attached to the same categories in many cases, but not all.

    Posted 12 years ago on Saturday March 31, 2012 | Permalink