Title: Unable to Add Exceptions through code &#8211; array as a string errors
Last modified: April 12, 2022

---

# Unable to Add Exceptions through code – array as a string errors

 *  Resolved [abhilaksh235](https://wordpress.org/support/users/abhilaksh235/)
 * (@abhilaksh235)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/unable-to-add-exceptions-through-code-array-as-a-string-errors/)
 * Hello,
 * I have a front-end form that creates posts (using gravity forms). I’m trying 
   to code a function that assigns edit exceptions to a set of user ids using the
   following code:
 *     ```
       // Change 1 in gform_advancedpostcreation_post_after_creation_1 to your form id number.
       add_filter( 'gform_advancedpostcreation_post_after_creation_28', 'gf_post_pp_edit_multiselect', 10, 4 );
       function gf_post_pp_edit_multiselect( $post_id, $feed, $entry, $form ) {
   
           // Checkboxes field id. Change this value to your field id number.
           $field_id = 2;
   
           // Get field object.
           $field = GFAPI::get_field( $form, $field_id );
   
           if ( $field->type == 'multiselect' ) {
               // Get a comma separated list of multiselect checked
               $selected = $field->get_value_export( $entry );
         		$reviewers = [];
               // Convert list of users to array with user ids.
               $reviewers = explode( ', ', $selected );
       		$reviewerVals = array_values($reviewers);
           }
   
       	GFCommon::log_debug( __METHOD__ . '(): reviewers => ' . print_r( $reviewers, true ) );
       	GFCommon::log_debug( __METHOD__ . '(): reviewerVals => ' . print_r( $reviewerVals, true ) );
       	GFCommon::log_debug( __METHOD__ . '(): selected => ' . print_r( $selected, true ) );
       //	reviewers => Array
       //	(
       //    [0] => 7
       //    [1] => 8
       //    [2] => 97
       //	)
   
       	// enable all members of this group to read pages which are in the specified term
       $args = array(
       	'operation' => 'read',
       	'mod_type' => 'additional',
       	'for_item_source' => 'post',
       	'for_item_type' => 'post', 
       	'via_item_source' => 'post',
       	'item_id' => $post_id, 
       );
   
       GFCommon::log_debug( __METHOD__ . '(): ppc_arguments => ' . print_r( $args, true ) );
   
       ppc_assign_exceptions ( $reviewerVals, 'user', $args );
       //tried with $reviewers, $reviewerVals, $selected - no luck!
   
       	GFCommon::log_debug( __METHOD__ . '(): ppc_assign_exceptions output => ' . print_r(ppc_assign_exceptions ( $reviewers, 'user', $args )) );
   
       }
       ```
   
 * Could you kindly help me?
 * The errors I get are:
    `Warning: array_keys() expects parameter 1 to be array,
   string given in ".../publishpress-permissions/classes/PublishPress/Permissions/
   DB/PermissionsUpdate.php " on line 183`
 * And so on and so forth.
 * What am I doing wrong? How am I supposed to call the ppc_assign_exceptions() 
   function for a set of users if I have their ids?

Viewing 1 replies (of 1 total)

 *  Plugin Author [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * (@stevejburge)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/unable-to-add-exceptions-through-code-array-as-a-string-errors/#post-15559196)
 * Hi [@abhilaksh235](https://wordpress.org/support/users/abhilaksh235/)
 * Thanks for using PublishPress Permissions.
 * Sorry, we’re not able to support custom code here on WordPress.org.
 * We do have technical support for Pro users, and we can accept bug reports here:
   [https://github.com/publishpress/PublishPress-permissions/](https://github.com/publishpress/PublishPress-permissions/)

Viewing 1 replies (of 1 total)

The topic ‘Unable to Add Exceptions through code – array as a string errors’ is 
closed to new replies.

 * ![](https://ps.w.org/press-permit-core/assets/icon-256x256.png?rev=3409953)
 * [PublishPress Permissions: Control User Access for Posts, Pages, Categories, Tags](https://wordpress.org/plugins/press-permit-core/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/press-permit-core/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/press-permit-core/)
 * [Active Topics](https://wordpress.org/support/plugin/press-permit-core/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/press-permit-core/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/press-permit-core/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/unable-to-add-exceptions-through-code-array-as-a-string-errors/#post-15559196)
 * Status: resolved