Title: Undefined pp_get_groups() error
Last modified: May 26, 2022

---

# Undefined pp_get_groups() error

 *  Resolved [Xavier Serrano](https://wordpress.org/support/users/xavierserranoa/)
 * (@xavierserranoa)
 * [4 years ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/)
 * getting this error An error of type E_ERROR was caused in line 121 of the file/
   code/wp-content/themes/crate/inc/filters.php. Error message: Uncaught Error: 
   Call to undefined function CShop\Crate\pp_get_groups() in /code/wp-content/themes/
   crate/inc/filters.php:121
 * setting \pp_get_groups() does not work either. do we need to do something to 
   make sure the api file press-permit-core/library/api-legacy.php is loaded correctly
   when trying to use the function from a hook in the theme files?

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

 *  Plugin Author [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [4 years ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15682665)
 * [@xavierserranoa](https://wordpress.org/support/users/xavierserranoa/) Make sure
   that call is within a function that’s hooked to the ‘plugins_loaded’ or ‘init’
   action, not executing immediately when your code module loads.
    -  This reply was modified 4 years ago by [Kevin Behrens](https://wordpress.org/support/users/kevinb/).
 *  Thread Starter [Xavier Serrano](https://wordpress.org/support/users/xavierserranoa/)
 * (@xavierserranoa)
 * [4 years ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15682669)
 * [@kevinb](https://wordpress.org/support/users/kevinb/) its performed within the‘
   admin_init’ hook
 *  Thread Starter [Xavier Serrano](https://wordpress.org/support/users/xavierserranoa/)
 * (@xavierserranoa)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15707106)
 * [@kevinb](https://wordpress.org/support/users/kevinb/) anymore info as to what
   else could be happening?
 *  Thread Starter [Xavier Serrano](https://wordpress.org/support/users/xavierserranoa/)
 * (@xavierserranoa)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15707119)
 * we are using namespaces is that maybe why?
 *  Plugin Author [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * (@stevejburge)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15707178)
 * Hi [@xavierserranoa](https://wordpress.org/support/users/xavierserranoa/)
 * Sorry, we don’t normally send our developers to help with custom code here on
   WordPress.org. Support for custom code is normally for our Pro members.
 * I will ask Kevin to circle back, but it may be next week at the earliest.
 *  Plugin Author [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15713904)
 * Does the error still occur if you call this instead – passing the same arguments
   as to pp_groups()?
 * \PublishPress\Permissions\API::getGroups()
 *  Thread Starter [Xavier Serrano](https://wordpress.org/support/users/xavierserranoa/)
 * (@xavierserranoa)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15716924)
 * [@kevinb](https://wordpress.org/support/users/kevinb/) yes the issue does persist
   although a bit different
 * `Fatal error: Uncaught Error: Class 'PublishPress\Permissions\API' not found 
   in`
 *  Plugin Author [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15727092)
 * [@xavierserranoa](https://wordpress.org/support/users/xavierserranoa/) Yes, if
   your code is truly executing on the admin_init action, that code module should
   be loaded already. But if something has gone wrong, you can load it manually 
   right before your function call:
 * `require_once(PRESSPERMIT_ABSPATH . '/library/api-legacy.php');`
 *  Thread Starter [Xavier Serrano](https://wordpress.org/support/users/xavierserranoa/)
 * (@xavierserranoa)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15727605)
 * [@kevinb](https://wordpress.org/support/users/kevinb/) the issue still appears
   as such
 * `Fatal error: Uncaught Error: Class 'PublishPress\Permissions\API' not found 
   in /code/wp-content/plugins/press-permit-core/library/api-legacy.php:95 Stack
   trace: #0 /code/wp-content/themes/crate/inc/filters.php(124): pp_get_groups('
   pp_group', Array) #1 /code/wp-includes/class-wp-hook.php(307): CShop\Crate\add_custom_group_caps('')#
   2 /code/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)#
   3 /code/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #4 /code/wp-admin/
   admin.php(175): do_action('admin_init') #5 /code/wp-admin/customize.php(13): 
   require_once('/code/wp-admin/...') #6 {main} thrown in /code/wp-content/plugins/
   press-permit-core/library/api-legacy.php on line 95`
 * keep in mind this issue happens when trying to access the customizer in wordpress
   admin. so something in your code is causing the plugin to not load correctly 
   when on the customizer. I dont think its the code we are using.
 *  Plugin Author [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15727691)
 * [@xavierserranoa](https://wordpress.org/support/users/xavierserranoa/) What Permissions
   version are you running?
 *  Plugin Author [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15727698)
 * [@xavierserranoa](https://wordpress.org/support/users/xavierserranoa/)
 * The stack trace shows this is related to your custom code. Please add this statement
   before your function call:
 * require_once(PRESSPERMIT_CLASSPATH . ‘/API.php’);
 *  Thread Starter [Xavier Serrano](https://wordpress.org/support/users/xavierserranoa/)
 * (@xavierserranoa)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15733527)
 * [@kevinb](https://wordpress.org/support/users/kevinb/) it is now throwing this
 * `Warning: Use of undefined constant PRESSPERMIT_READ_PUBLIC_CAP - assumed 'PRESSPERMIT_READ_PUBLIC_CAP'(
   this will throw an Error in a future version of PHP) in /code/wp-content/plugins/
   press-permit-core/classes/PublishPress/Permissions/Roles.php on line 21 Fatal
   error: Uncaught Error: Call to a member function filteringEnabled() on null in/
   code/wp-content/plugins/press-permit-core/classes/PublishPress/Permissions.php:
   427 Stack trace: #0 /code/wp-content/plugins/press-permit-core/classes/PublishPress/
   PermissionsHooks.php(425): PublishPress\Permissions->filteringEnabled() #1 /code/
   wp-content/plugins/press-permit-core/classes/PublishPress/PermissionsHooks.php(
   339): PublishPress\PermissionsHooks->loadContentFilters() #2 /code/wp-content/
   plugins/press-permit-core/classes/PublishPress/PermissionsHooks.php(281): PublishPress\
   PermissionsHooks->loadInitFilters() #3 /code/wp-content/plugins/press-permit-
   core/classes/PublishPress/PermissionsHooks.php(157): PublishPress\PermissionsHooks-
   >actInitUser() #4 /code/wp-content/plugins/press-permit-core/classes/PublishPress/
   PermissionsHooks.php(112): PublishPress\PermissionsHooks->actSetCurrentUser()#
   5 /code/wp-content/plugins/press-permit-core/classes/PublishPress/PermissionsHooks.
   php(32): PublishPress\PermissionsHooks->loadFilters() #6 /c in /code/wp-content/
   plugins/press-permit-core/classes/PublishPress/Permissions.php on line 427`
 * you should be able to replicate this issue by using this
 *     ```
       /**
        * Modify custom permission group user capabilities
        */
       function add_custom_group_caps() {
       	require_once(PRESSPERMIT_CLASSPATH . '/API.php');
       	require_once(PRESSPERMIT_ABSPATH . '/library/api-legacy.php');
       	// Allow anyone assigned to a custom group the cap to upload files
       	$groups = pp_get_groups(
       		'pp_group',
       		array(
       			'cols'            => 'id',
       			'skip_meta_types' => array( 'wp_role' ),
       		)
       	);
       	foreach ( $groups as $group ) {
       		$custom_group_users = pp_get_group_members( $group->id, 'pp_group', 'id' );
       		foreach ( $custom_group_users as $user_id ) {
       			$user = new \WP_User( $user_id );
       			$user->add_cap( 'upload_files' );
       			$user->add_cap( 'list_others_unattached_files' );
       			$user->add_cap( 'pp_list_all_files' );
       		}
       	}
       }
       add_action( 'admin_init', __NAMESPACE__ . '\add_custom_group_caps' );
       ```
   
 * then go to the customizer and you’ll see the error.
 * version is 3.7.8
 *  Plugin Author [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * (@stevejburge)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15733531)
 * [@xavierserranoa](https://wordpress.org/support/users/xavierserranoa/) Thanks.
   We really are a long way beyond the normal level of support we offer here for
   custom code on WordPress.org.
 * Please consider a Pro membership for more detailed help with your code.
 * Or if you have pin-pointed a bug, you’re welcome to submit it here: [https://github.com/publishpress/PublishPress-Permissions/issues](https://github.com/publishpress/PublishPress-Permissions/issues)

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

The topic ‘Undefined pp_get_groups() error’ 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/)

 * 13 replies
 * 3 participants
 * Last reply from: [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/undefined-pp_get_groups-error/#post-15733531)
 * Status: resolved