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:

   <?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']; 
   }  ?>

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.

Leave a Reply

Your email address will not be published. Required fields are marked *