Title: Error &#8220;implode(): Invalid arguments&#8221; when using register_rest_route
Last modified: November 14, 2018

---

# Error “implode(): Invalid arguments” when using register_rest_route

 *  Resolved [patternmb](https://wordpress.org/support/users/patternmb/)
 * (@patternmb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/error-implode-invalid-arguments-when-using-register_rest_route/)
 * Hello,
 * I’ve encountered an issue that was causing me some problems; when using wp_add_object_terms
   with register_rest_route it gives this error:
 * _Warning: implode(): Invalid arguments passed in C:\wamp64\www\wp-tester\wp-content\
   plugins\wp-security-audit-log\classes\Sensors\Content.php on line 898_
 * PHP code example:
 *     ```
       add_action( 'rest_api_init', function () {
           register_rest_route( 'my-rest-route/v1', '/example/', array(
           'methods' => 'POST',
           'callback' => 'rest_api_callback_action'
         ));
       });
       function rest_api_callback_action($request)
       {
         $testAddCat = wp_add_object_terms(5, 'test-category', 'custom-categories');
         echo 'Success';
         die();
       }
       ```
   
 * While I am using a custom post type and assigning a category from a custom taxonomy
   when the rest API is called in the example above, the issue persists when assigning
   a default category to a default post.
 * It appears that in the Content.php file the function gutenberg_post_terms_changed
   calls $this->CheckCategoriesChange() but does not pass any value for the $old_cats
   parameter. As a temporary fix I’ve added a couple if statements:
 *     ```
       protected function CheckCategoriesChange( $old_cats, $new_cats, $post ) {
       if( !is_array($old_cats) ) {
         $old_cats = array();
       }
       if( !is_array($new_cats) ) {
        $new_cats = array();			
       }
       $old_cats = implode( ', ', $old_cats );
       $new_cats = implode( ', ', $new_cats );
       ...
       ```
   
 * Other Details:
    - WordPress version: 4.9.8
    - WP Security Audit Log plugin version: 3.2.4
    - No other WordPress plugins active, only the default Hello Dolly and Akismet
      Anti-Spam are installed but inactive.
    - Fresh local install with wampserver 3.1.0
    - PHP version 5.6.31
 * Cheers!
    -  This topic was modified 7 years, 6 months ago by [patternmb](https://wordpress.org/support/users/patternmb/).
      Reason: Made other details, slightly more clear

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/error-implode-invalid-arguments-when-using-register_rest_route/#post-10883492)
 * Thanks [@patternmb](https://wordpress.org/support/users/patternmb/) for reporting
   this and the recommendation. We will add a fix for this in the next update of
   the plugin (3.3).
 * We just released a minor update today but should be releasing 3.3 before the 
   festive season.
 * Stay tuned and do not hesitate to reach out in case you need further assistance.
 *  Thread Starter [patternmb](https://wordpress.org/support/users/patternmb/)
 * (@patternmb)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/error-implode-invalid-arguments-when-using-register_rest_route/#post-10885033)
 * Awesome, I look forward to 3.3. I’ll retest my code when it comes out and if 
   there are no issues we can mark this as resolved.
 * Thanks!
 *  [WPWhiteSecurity](https://wordpress.org/support/users/wpwhitesecurity/)
 * (@wpwhitesecurity)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/error-implode-invalid-arguments-when-using-register_rest_route/#post-10983375)
 * Hello [@patternmb](https://wordpress.org/support/users/patternmb/),
 * We have just released update 3.3 and can confirm that we have included the fix.
   You can read more about the latest WP Security Audit Log plugin update in these
   [release notes](https://www.wpsecurityauditlog.com/releases/external-connections-update-slack-support-3-3/).
 *  Thread Starter [patternmb](https://wordpress.org/support/users/patternmb/)
 * (@patternmb)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/error-implode-invalid-arguments-when-using-register_rest_route/#post-10986542)
 * [@wpwhitesecurity](https://wordpress.org/support/users/wpwhitesecurity/) [@robert681](https://wordpress.org/support/users/robert681/)
 * Thank you for the update. I’ve just tried 3.3 and everything is looking good.
 *  Plugin Support [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/error-implode-invalid-arguments-when-using-register_rest_route/#post-10987397)
 * You’re welcome and thank you for the positive review.
 * Have a great day and do not hesitate to reach out to us should you have any queries.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Error “implode(): Invalid arguments” when using register_rest_route’ 
is closed to new replies.

 * ![](https://ps.w.org/wp-security-audit-log/assets/icon-256x256.png?rev=2961534)
 * [WP Activity Log](https://wordpress.org/plugins/wp-security-audit-log/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-security-audit-log/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-security-audit-log/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-security-audit-log/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-security-audit-log/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-security-audit-log/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [robertabela](https://wordpress.org/support/users/robert681/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/error-implode-invalid-arguments-when-using-register_rest_route/#post-10987397)
 * Status: resolved