• Resolved jaclas

    (@jaclas)


    I defined a list of 6 roles and gave each role a priority: 15, 30, 50, 150, 500 and 1000.
    Is there a way to read the role priority at the PHP code level?

    function getUserRolePriority()

    <span style=”text-decoration: underline;”>How to implement this?</span>

    The other thing is I would like to use functions in text fields that restrict access, such as this one:

    [um_show_content role='um_some_role']

    But I would like not to specify in the condition the ID of the role, but its <span style=”text-decoration: underline;”>priority, how to do it</span>?
    Is there something similar?

    [um_show_content priority>=150] ?

    <span style=”text-decoration: underline;”>Are there such functions?</span>

Viewing 4 replies - 1 through 4 (of 4 total)
  • @jaclas

    You will find the UM Role functions in:

    .../plugins/ultimate-member/includes/core/class-roles-capabilities.php

    Thread Starter jaclas

    (@jaclas)

    Thx for hint.

    if anyone needs it, I publish the function code that returns the priority of the role assigned to the logged in user:

    function getUserRolePriority() {
    $um_roles_keys = get_option( 'um_roles', array() );
    $userrole = UM()->user()->get_role();
    if (str_starts_with($userrole, 'um_')) {
    $userrole = substr($userrole, 3);
    }
    $rolemeta = get_option( "um_role_{$userrole}_meta", false );
    if ( ! $rolemeta ) {
    $prio = 0;
    } else {
    $prio = ! empty( $rolemeta['_um_priority'] ) ? $rolemeta['_um_priority'] : 0;
    }
    return $prio;
    }

    Plugin Support andrewshu

    (@andrewshu)

    Hello @jaclas

    Did you solve your question? Can I close this topic?

    Thank you.

    Thread Starter jaclas

    (@jaclas)

    yes, thx

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Priorities of roles, how to get?’ is closed to new replies.