WordPress: Improvement to Form Manager plugin when used with Members plugin

As mentioned in my earlier post, the WordPress Form Manager and Member’s plugins integrate fantastically. However, one thing that didn’t quite perfectly was that if a user was allowed to view the submission data for forms (the ‘

This is because, by default, clicking on the name of a form takes you to the edit/design page, whether or not you are allowed to edit the form. Therefore, if you are not allowed to edit the form, it doesn’t show the page, and you see nothing except the tabs for the actions that you are allowed to access, in this case the “Submission Data” tab. To see the submission data, you then have to click on this tab to view the data. Obviously, this second click is annoying, and the blank page is ugly/confusing.

Thankfully, this issue was quite easy to fix, by replacing line 155 of wordpress-form-manager/pages/main.php with the following code:

<strong>
   <?php if(!$fm_MEMBERS_EXISTS || current_user_can('form_manager_forms') || current_user_can('form_manager_data')) { ?>
      <a class="row-title" href="<?php
      //If the user can edit forms, take them to the edit page, as usual
      if(!$fm_MEMBERS_EXISTS || current_user_can('form_manager_forms')) { 
         echo get_admin_url(null, 'admin.php')."?page=fm-edit-form&sec=design&id=".$form['ID'];
      }
      //Otherwise, if the user can view the data, take them to the data page
      else if(current_user_can('form_manager_data')) { 
         echo get_admin_url(null, 'admin.php')."?page=fm-edit-form&sec=data&id=".$form['ID'];
      }
   ?>"><?php echo $form['title'];?></a>
   <?php } 
   //If user has no form permissions, do not create a link
   else { 
      echo $form['title']; 
   }  ?>
</strong>

Basically this just means that:

  • If the Members plugin isn’t installed, the link goes to the edit/design page
  • If the user can edit forms, the link goes to the edit/design page
  • If the user can’t edit forms but can view data, the link goes to the submission data page
  • If the user can’t edit forms or view data (i.e. they can do nothing with individual forms), then the form name isn’t made into a link

I hope this is a robust improvement – it seems to work well for me, and will prevent my ‘view data only’ users from getting annoyed/confused by the form link taking them to the wrong place.

WordPress Form Manager and Members plugins integrate brilliantly

We’ve been working with the WordPress Form Manager plugin for a while, and have found it an excellent and flexible way to create forms in WordPress (thanks Campbell Hoffman). However, I was initially struggling when trying to change the way the permissions worked within the plugin.

By default, only site administrators get to see the forms menu item in the Dashboard, and only they can edit forms, view submission data etc. I wanted to allow other roles (e.g. Contributors) to view submission data, but, ideally, not to edit forms, change advanced form settings etc, or edit posts etc. Therefore, I started looking around in the Form Manager plugin code to see if I could change things to allow different roles to do different things and was getting confused by things like the $fm_MEMBERS_EXISTS variable. What I should have done, as always, is look at the docs for the plugin, where I would have found (and eventually did find) this: http://www.campbellhoffman.com/form-manager-faq/#how-do-i-restrict-access-to-different-parts-of-form-manager-members

It turns out that the Form Manager plugin integrates with Justin Tadlock’s Member’s plugin, which in itself seems like an excellent plugin, allowing you to change the capabilities associated with different roles, create your own roles and more. As an aside, users, roles and capabilities in WordPress can be confusing, but Justin’s post on the what they all mean makes it much less so.

Therefore, combining these two plugins allowed me to create a new role that has very limited capabilities. Alongside the standard ‘read’ capability, all they can do is view the list of available forms (the ‘form_manager_main’ capability), view the submission data table (‘

In conclusion, I would say the Members plugin is a ‘must have’ if you want something other than the standard roles offered by WordPress and the Form Manager plugin, of which I was already a fan, is made all the better thanks to its ability to integrate with Members.