studio-arrenberg / quartiersplattform

🏡 Repo für die Quartiersplattform
https://arrenberg.app
MIT License
2 stars 3 forks source link

PHP 8 results in "fatal error" when registering a new user! #129

Closed Uatschitchun closed 1 year ago

Uatschitchun commented 2 years ago

When using php 8, registering a new user gives the following error:

Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "my_registration_user_role" not found or invalid function name in /my_site/wordpress/wp-includes/class-wp-hook.php:307 Stack trace: #0 /my_site/wordpress/wp-includes/plugin.php(191): WP_Hook->apply_filters('contributor', Array) #1 /my_site/wordpress/wp-content/plugins/ultimate-member/includes/core/um-actions-register.php(466): apply_filters('um_registration...', 'contributor', Array) #2 /my_site/wordpress/wp-includes/class-wp-hook.php(307): um_submit_form_register(Array) #3 /my_site/wordpress/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array) #4 /my_site/wordpress/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #5 /my_site/wordpress/wp-content/plugins/ultimate-member/includes/core/class-form.php(581): do_action('um_submit_form_...', Array) #6 /my_site/wordpress/wp-includes/class-wp-hook.php(307): um\core\Form->form_init('') #7 /my_site/wordpress/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(false, Array) #8 /my_site/wordpress/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #9 /my_site/wordpress/wp-includes/template-loader.php(13): do_action('template_redire...') #10 /my_site/wordpress/wp-blog-header.php(19): require_once('/homepages/34/d...') #11 /my_site/wordpress/index.php(17): require('/homepages/34/d...') #12 {main} thrown in /my_site/wordpress/wp-includes/class-wp-hook.php on line 307

Oh dear, this one took me ages to solve! ;( I even completely re-installed WP and did the setup from the beginning as I've thought I mis-configured something in regards to the "Standard" user-role. Dear was I wrong ;) Advantage: I noted every step and will provide it as a help to install QP.

This one was solved on my side by switching to php 7.4 on provider side.

Question: Where to set the "Standard" user-role?

j0hannr commented 1 year ago

Updating sometimes helps ;)

The default user role is contributor. Set in functions.php

/**
 * Hijack Default User Role
 *
 * @since Quartiersplattform 1.7
 * 
 * @return string
 */
add_filter('pre_option_default_role', function($default_role){
    return 'contributor'; // This is changed
    return $default_role; // This allows default
});