• Resolved Xavier Serrano

    (@xavierserranoa)


    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

    (@kevinb)

    @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 2 years, 10 months ago by Kevin Behrens.
    Thread Starter Xavier Serrano

    (@xavierserranoa)

    @kevinb its performed within the ‘admin_init’ hook

    Thread Starter Xavier Serrano

    (@xavierserranoa)

    @kevinb anymore info as to what else could be happening?

    Thread Starter Xavier Serrano

    (@xavierserranoa)

    we are using namespaces is that maybe why?

    Plugin Author Steve Burge

    (@stevejburge)

    Hi @xavierserranoa

    Sorry, we don’t normally send our developers to help with custom code here on www.remarpro.com. 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

    (@kevinb)

    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

    (@xavierserranoa)

    @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

    (@kevinb)

    @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

    (@xavierserranoa)

    @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

    (@kevinb)

    @xavierserranoa What Permissions version are you running?

    Plugin Author Kevin Behrens

    (@kevinb)

    @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

    (@xavierserranoa)

    @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

    (@stevejburge)

    @xavierserranoa Thanks. We really are a long way beyond the normal level of support we offer here for custom code on www.remarpro.com.

    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

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Undefined pp_get_groups() error’ is closed to new replies.