1

I'm working with Wordpress and a plugin called WPL. Basically, the system is set up so that my WP users are, upon sign up, automatically activated as WPL users. However, I need to have this differentiated based on user roles. So, I have four different WP roles, and four corresponding WPL roles. I think I found the code where WPL extracts the code information.

public static function get_wpl_roles()
{
    $roles = array();
    $roles['superadmin'] = 'superadmin';
    $roles['admin'] = 'administrator';
    $roles['editor'] = 'editor';
    $roles['agent'] = 'author';
    $roles['Contributor'] = 'Contributor';
    $roles['subscriber'] = 'subscriber';
    $roles['guest'] = 'guest';
    $roles['ten'] = 'ten';
    $roles['trio'] = 'trio';
    $roles['single'] = 'single';
    $roles['unlimited'] = 'unlimited';

    return $roles;
}

/**
    @input {role}
    @return role point
    @author Howard
**/
public static function get_role_point($role)
{
    /** get all roles **/
    $roles = self::get_wpl_roles();

    /** role validation **/
    if(!in_array($role, $roles)) $role = 'guest';

    $roles_point = array();
    $roles_point['superadmin'] = 6;
    $roles_point['administrator'] = 5;
    $roles_point['editor'] = 4;
    $roles_point['author'] = 3;
    $roles_point['Contributor'] = 2;
    $roles_point['subscriber'] = 1;
    $roles_point['guest'] = 0;

    return $roles_point[$role];
}

The last four roles in the top section (ten, trio, single, and unlimited) are my WP roles. When someone signs up under one of these roles, I want them to be automatically instated under the same role headings (which have been created already) in WPL.

Right now, all WP users are automatically instated as WPL users under the default role. Which I'm guessing is because of this line:

    if(!in_array($role, $roles)) $role = 'guest';

But I can't seem to find where 'guest' is defined. The default WPL role is just called 'Default', not guest. So, I'm confused there.

The second part of the code has numbers involved - so I am not sure how to add my other four roles. And I assume I need four new sections under a different if statement.

d33tah
  • 10,999
  • 13
  • 68
  • 158
Beck
  • 51
  • 6

0 Answers0