dongqiao8421 2014-09-29 18:27
浏览 26

使用Wordpress插件的PHP手持

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 Revit2020下载问题
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线