当前位置: 首页>>代码示例>>PHP>>正文


PHP bbp_get_dynamic_roles函数代码示例

本文整理汇总了PHP中bbp_get_dynamic_roles函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_dynamic_roles函数的具体用法?PHP bbp_get_dynamic_roles怎么用?PHP bbp_get_dynamic_roles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bbp_get_dynamic_roles函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: d4p_bbpress_get_user_roles

 /**
  * Get valid roles for forums based on bbPress version
  *
  * @return array list of roles
  */
 function d4p_bbpress_get_user_roles()
 {
     $roles = array();
     $dynamic_roles = bbp_get_dynamic_roles();
     foreach ($dynamic_roles as $role => $obj) {
         $roles[$role] = $obj['name'];
     }
     return $roles;
 }
开发者ID:alvarpoon,项目名称:anbig,代码行数:14,代码来源:shared.php

示例2: d4p_bbpress_get_user_roles

 /**
  * Get valid roles for forums based on bbPress version
  *
  * @return array list of roles
  */
 function d4p_bbpress_get_user_roles()
 {
     $roles = array();
     if (d4p_bbpress_version() < 22) {
         global $wp_roles;
         foreach ($wp_roles->role_names as $role => $title) {
             $roles[$role] = $title;
         }
     } else {
         $dynamic_roles = bbp_get_dynamic_roles();
         foreach ($dynamic_roles as $role => $obj) {
             $roles[$role] = $obj['name'];
         }
     }
     return $roles;
 }
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:21,代码来源:shared.php

示例3: user_role_row

 /**
  * Return user's forums role for display in the WordPress Users list table
  *
  * @since bbPress (r4337)
  *
  * @param string $retval
  * @param string $column_name
  * @param int $user_id
  *
  * @return string Displayable bbPress user role
  */
 public static function user_role_row($retval = '', $column_name = '', $user_id = 0)
 {
     // Only looking for bbPress's user role column
     if ('bbp_user_role' === $column_name) {
         // Get the users role
         $user_role = bbp_get_user_role($user_id);
         $retval = false;
         // Translate user role for display
         if (!empty($user_role)) {
             $roles = bbp_get_dynamic_roles();
             $retval = translate_user_role($roles[$user_role]['name']);
         }
     }
     // Pass retval through
     return $retval;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:27,代码来源:users.php

示例4: bbp_get_user_role

/**
 * Return a user's forums role
 *
 * @since bbPress (r3860)
 *
 * @param int $user_id
 * @uses bbp_get_user_id() To get the user id
 * @uses get_userdata() To get the user data
 * @uses apply_filters() Calls 'bbp_get_user_role' with the role and user id
 * @return string
 */
function bbp_get_user_role($user_id = 0)
{
    // Validate user id
    $user_id = bbp_get_user_id($user_id);
    $user = get_userdata($user_id);
    $role = false;
    // User has roles so look for a bbPress one
    if (!empty($user->roles)) {
        // Look for a bbPress role
        $roles = array_intersect(array_values($user->roles), array_keys(bbp_get_dynamic_roles()));
        // If there's a role in the array, use the first one. This isn't very
        // smart, but since roles aren't exactly hierarchical, and bbPress
        // does not yet have a UI for multiple user roles, it's fine for now.
        if (!empty($roles)) {
            $role = array_shift($roles);
        }
    }
    return apply_filters('bbp_get_user_role', $role, $user_id, $user);
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:30,代码来源:capabilities.php

示例5: bbp_edit_user_forums_role

/**
 * Output forum role selector (for user edit)
 *
 * @since 2.2.0 bbPress (r4284)
 */
function bbp_edit_user_forums_role()
{
    // Return if no user is being edited
    if (!bbp_is_single_user_edit()) {
        return;
    }
    // Get the user's current forum role
    $user_role = bbp_get_user_role(bbp_get_displayed_user_id());
    // Get the folum roles
    $dynamic_roles = bbp_get_dynamic_roles();
    // Only keymasters can set other keymasters
    if (!bbp_is_user_keymaster()) {
        unset($dynamic_roles[bbp_get_keymaster_role()]);
    }
    ?>

	<select name="bbp-forums-role" id="bbp-forums-role">
		<option value=""><?php 
    esc_html_e('&mdash; No role for these forums &mdash;', 'bbpress');
    ?>
</option>

		<?php 
    foreach ($dynamic_roles as $role => $details) {
        ?>

			<option <?php 
        selected($user_role, $role);
        ?>
 value="<?php 
        echo esc_attr($role);
        ?>
"><?php 
        echo bbp_translate_user_role($details['name']);
        ?>
</option>

		<?php 
    }
    ?>

	</select>

	<?php 
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:50,代码来源:template.php

示例6: bbp_remove_roles

/**
 * Removes bbPress-specific user roles.
 *
 * @since bbPress (r2741)
 * @deprecated since version 2.2
 */
function bbp_remove_roles()
{
    // Remove the bbPress roles
    foreach (array_keys(bbp_get_dynamic_roles()) as $bbp_role) {
        remove_role($bbp_role);
    }
    // Some early adopters may have a deprecated visitor role. It was later
    // replaced by the Spectator role.
    remove_role('bbp_visitor');
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:16,代码来源:capabilities.php

示例7: get_user_roles

 function get_user_roles()
 {
     $bbp_roles = bbp_get_dynamic_roles();
     $keymaster = bbp_get_keymaster_role();
     $moderator = bbp_get_moderator_role();
     $blocked = bbp_get_blocked_role();
     // double check if the role exists
     if (isset($bbp_roles[$keymaster])) {
         unset($bbp_roles[$keymaster]);
     }
     if (isset($bbp_roles[$moderator])) {
         unset($bbp_roles[$moderator]);
     }
     if (isset($bbp_roles[$blocked])) {
         unset($bbp_roles[$blocked]);
     }
     $bbp_roles['bbpkr_anonymous'] = array('name' => __('Anonymous', 'bbpresskr'), 'caps' => array('spectate' => true));
     return $bbp_roles;
 }
开发者ID:082net,项目名称:bbpresskr,代码行数:19,代码来源:core.php

示例8: array_values

// output primary role selection dropdown list
$this->user_primary_role_dropdown_list($this->user_to_edit->roles);
$values = array_values($this->user_to_edit->roles);
$primary_role = array_shift($values);
// get 1st element from roles array
if (function_exists('bbp_filter_blog_editable_roles')) {
    // bbPress plugin is active
    ?>
	
	<div style="margin-top: 5px;margin-bottom: 5px; font-weight: bold;"><?php 
    esc_html_e('bbPress Role:', 'ure');
    ?>
</div>
<?php 
    // Get the roles
    $dynamic_roles = bbp_get_dynamic_roles();
    $bbp_user_role = bbp_get_user_role($this->user_to_edit->ID);
    if (!empty($bbp_user_role)) {
        echo $dynamic_roles[$bbp_user_role]['name'];
    }
}
?>
			<div style="margin-top: 5px;margin-bottom: 5px; font-weight: bold;"><?php 
esc_html_e('Other Roles:', 'ure');
?>
</div>
<?php 
foreach ($this->roles as $role_id => $role) {
    if (($show_admin_role || $role_id != 'administrator') && $role_id !== $primary_role) {
        if ($this->user_can($role_id)) {
            $checked = 'checked="checked"';
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:31,代码来源:ure-user-edit.php

示例9: bbp_admin_setting_callback_global_access

/**
 * Allow global access setting field
 *
 * @since 2.0.0 bbPress (r3378)
 *
 * @uses checked() To display the checked attribute
 */
function bbp_admin_setting_callback_global_access()
{
    // Get the default role once rather than loop repeatedly below
    $default_role = bbp_get_default_role();
    // Start the output buffer for the select dropdown
    ob_start();
    ?>

	</label>
	<label for="_bbp_default_role">
		<select name="_bbp_default_role" id="_bbp_default_role" <?php 
    bbp_maybe_admin_setting_disabled('_bbp_default_role');
    ?>
>
		<?php 
    foreach (bbp_get_dynamic_roles() as $role => $details) {
        ?>

			<option <?php 
        selected($default_role, $role);
        ?>
 value="<?php 
        echo esc_attr($role);
        ?>
"><?php 
        echo translate_user_role($details['name']);
        ?>
</option>

		<?php 
    }
    ?>
		</select>

	<?php 
    $select = ob_get_clean();
    ?>

	<label for="_bbp_allow_global_access">
		<input name="_bbp_allow_global_access" id="_bbp_allow_global_access" type="checkbox" value="1" <?php 
    checked(bbp_allow_global_access(true));
    bbp_maybe_admin_setting_disabled('_bbp_allow_global_access');
    ?>
 />
		<?php 
    printf(esc_html__('Automatically give registered visitors the %s forum role', 'bbpress'), $select);
    ?>
	</label>

<?php 
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:58,代码来源:settings.php

示例10: display

    public function display()
    {
        $caps_readable = $this->lib->get('caps_readable');
        $show_deprecated_caps = $this->lib->get('show_deprecated_caps');
        $edit_user_caps_mode = $this->lib->get_edit_user_caps_mode();
        $caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
        $user_info = $this->get_user_info();
        ?>

<div class="postbox" style="float:left;min-width:1000px;width: 100%;">
    <div id="ure_user_caps_header">
        <span id="ure_user_caps_title"><?php 
        esc_html_e('Change capabilities for user', 'user-role-editor');
        ?>
</span> <?php 
        echo $user_info;
        ?>
    </div>
    <div class="inside"> 
<table cellpadding="0" cellspacing="0" style="width: 100%;">
	<tr>
		<td>&nbsp;</td>		
		<td style="padding-left: 10px; padding-bottom: 5px;">
  <?php 
        if (is_super_admin() || !$this->multisite || !class_exists('User_Role_Editor_Pro') || !$caps_access_restrict_for_simple_admin) {
            if ($caps_readable) {
                $checked = 'checked="checked"';
            } else {
                $checked = '';
            }
            ?>
  
		<input type="checkbox" name="ure_caps_readable" id="ure_caps_readable" value="1" 
      <?php 
            echo $checked;
            ?>
 onclick="ure_turn_caps_readable(<?php 
            echo $this->user_to_edit->ID;
            ?>
);"  />
    <label for="ure_caps_readable"><?php 
            esc_html_e('Show capabilities in human readable form', 'user-role-editor');
            ?>
</label>&nbsp;&nbsp;&nbsp;
<?php 
            if ($show_deprecated_caps) {
                $checked = 'checked="checked"';
            } else {
                $checked = '';
            }
            ?>
    <input type="checkbox" name="ure_show_deprecated_caps" id="ure_show_deprecated_caps" value="1" 
        <?php 
            echo $checked;
            ?>
 onclick="ure_turn_deprecated_caps(<?php 
            echo $this->user_to_edit->ID;
            ?>
);"/>
    <label for="ure_show_deprecated_caps"><?php 
            esc_html_e('Show deprecated capabilities', 'user-role-editor');
            ?>
</label>      
<?php 
        }
        ?>
		</td>
	</tr>	
	<tr>
		<td id="ure_user_roles">
			<div class="ure-user-role-section-title"><?php 
        esc_html_e('Primary Role:', 'user-role-editor');
        ?>
</div>
<?php 
        $this->show_primary_role_dropdown_list($this->user_to_edit->roles);
        if (function_exists('bbp_filter_blog_editable_roles')) {
            // bbPress plugin is active
            ?>
	
	<div class="ure-user-role-section-title" style="margin-top: 5px;"><?php 
            esc_html_e('bbPress Role:', 'user-role-editor');
            ?>
</div>
<?php 
            $dynamic_roles = bbp_get_dynamic_roles();
            $bbp_user_role = bbp_get_user_role($this->user_to_edit->ID);
            if (!empty($bbp_user_role)) {
                echo $dynamic_roles[$bbp_user_role]['name'];
            }
        }
        ?>
			<div style="margin-top: 5px;margin-bottom: 5px; font-weight: bold;"><?php 
        esc_html_e('Other Roles:', 'user-role-editor');
        ?>
</div>
<?php 
        $this->show_secondary_roles();
        ?>
		</td>
//.........这里部分代码省略.........
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:101,代码来源:user-view.php

示例11: bbp_filter_blog_editable_roles

/**
 * Removes the bbPress roles from the editable roles array
 *
 * This used to use array_diff_assoc() but it randomly broke before 2.2 release.
 * Need to research what happened, and if there's a way to speed this up.
 *
 * @since bbPress (r4303)
 *
 * @param array $all_roles All registered roles
 * @return array 
 */
function bbp_filter_blog_editable_roles($all_roles = array())
{
    // Loop through bbPress roles
    foreach (array_keys(bbp_get_dynamic_roles()) as $bbp_role) {
        // Loop through WordPress roles
        foreach (array_keys($all_roles) as $wp_role) {
            // If keys match, unset
            if ($wp_role == $bbp_role) {
                unset($all_roles[$wp_role]);
            }
        }
    }
    return $all_roles;
}
开发者ID:hscale,项目名称:webento,代码行数:25,代码来源:capabilities.php

示例12: bbp_get_user_role

/**
 * Return a user's forums role
 *
 * @since bbPress (r3860)
 *
 * @param int $user_id
 * @uses bbp_get_user_id() To get the user id
 * @uses get_userdata() To get the user data
 * @uses apply_filters() Calls 'bbp_get_user_role' with the role and user id
 * @return string
 */
function bbp_get_user_role($user_id = 0)
{
    // Validate user id
    $user_id = bbp_get_user_id($user_id, false, false);
    $user = get_userdata($user_id);
    $role = false;
    // User has roles so lets
    if (!empty($user->roles)) {
        $roles = array_intersect(array_values($user->roles), array_keys(bbp_get_dynamic_roles()));
        // If there's a role in the array, use the first one
        if (!empty($roles)) {
            $role = array_shift(array_values($roles));
        }
    }
    return apply_filters('bbp_get_user_role', $role, $user_id, $user);
}
开发者ID:hscale,项目名称:webento,代码行数:27,代码来源:capabilities.php

示例13: bbp_admin_setting_callback_default_role

/**
 * Output forum role selector (for user edit)
 *
 * @since bbPress (r4284)
 */
function bbp_admin_setting_callback_default_role()
{
    $default_role = bbp_get_default_role();
    ?>

	<select name="_bbp_default_role" id="_bbp_default_role" <?php 
    bbp_maybe_admin_setting_disabled('_bbp_default_role');
    ?>
>

		<?php 
    foreach (bbp_get_dynamic_roles() as $role => $details) {
        ?>

			<option <?php 
        selected($default_role, $role);
        ?>
 value="<?php 
        echo esc_attr($role);
        ?>
"><?php 
        echo translate_user_role($details['name']);
        ?>
</option>

		<?php 
    }
    ?>

	</select>

	<?php 
}
开发者ID:hscale,项目名称:webento,代码行数:38,代码来源:settings.php


注:本文中的bbp_get_dynamic_roles函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。