[wp-testers] Call to undefined method WP_Roles::WP_Roles()

Dion Hulse (dd32) wordpress at dd32.id.au
Mon May 16 14:48:08 UTC 2011


The PHP4 style constructors were removed from the classes, as the php5
__construct() is used instead.

You should be able to safely remove this line:
$wp_roles->WP_Roles();
from the code, as it should not actually do anything. When $wp_roles is
instantated, that method (in previous versions) was called. If theres
something you're trying to work around, you should instead be calling
$wp_roles->_init();, but like i said, that shouldn't be needed at all.

On 17 May 2011 00:43, Michael Winkler <michi.mtrv at googlemail.com> wrote:

> Hi,
>
> I use in my plugins the following code to show a list of user roles:
>
> <?php
> global $wp_roles;
> $wp_roles->WP_Roles();
> foreach ($wp_roles->role_names as $roledex => $rolename) {
>       $role = $wp_roles->get_role($roledex);
>       $select = $role->has_cap('use_teachpress') ? 'selected="selected"' :
> '';
>       echo '<option value="'.$roledex.'"
> '.$select.'>'.$rolename.'</option>';
> }
> ?>
>
> The same code works with WordPress 2.8 to 3.1.2 but not in the current
> nightly build (WordPress 3.2-beta1-17916). In WP 3.2 I see only only the
> following error message:
> "Fatal error: Call to undefined method WP_Roles::WP_Roles() in [...]"
>
> Is it a bug or was it a planned change in the WP_Roles class?
>
> Kind regards,
> Michael
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
>


More information about the wp-testers mailing list