• Hey all,

    I’m getting a problem when I am trying to get the Role names used on one of my sites.

    Fatal error: Call to a member function get_names() on a non-object in C:\wamp\www\website\test\wp-content\plugins\reveal-ids\functions.php on line 57

    I am using the following syntax –

    global $wp_roles;
    $roles = $wp_roles->get_names();

    I have tried including ‘capabilities.php’ to see if the problem was this code being called first, but that did not work.

    Any help or pointers would be appriciated.

    Thanks

Viewing 1 replies (of 1 total)
  • Hey duck__boy, try this.

    global $wp_roles;
    if ( ! isset( $wp_roles ) ) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();

Viewing 1 replies (of 1 total)
  • The topic ‘Call to a member function get_names() on a non-object’ is closed to new replies.