本文整理汇总了PHP中bbp_get_user_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_get_user_id函数的具体用法?PHP bbp_get_user_id怎么用?PHP bbp_get_user_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bbp_get_user_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pg_get_user_replies_created
function pg_get_user_replies_created($user_id = 0)
{
// Validate user
$user_id2 = bbp_get_user_id($user_id);
$current_user = wp_get_current_user()->ID;
if (empty($user_id)) {
return false;
}
if (bbp_is_user_keymaster()) {
$limit = 'n';
}
if (user_can($current_user, 'moderate')) {
$check = get_user_meta($current_user, 'private_group', true);
if ($check == '') {
$limit = 'n';
}
}
if ($limit != 'n') {
global $wpdb;
$reply = bbp_get_reply_post_type();
$post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$reply}'");
//check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics
$allowed_posts = check_private_groups_reply_ids($post_ids);
}
// The default reply query with allowed topic and reply ids array added
// Try to get the topics
$query = bbp_has_replies(array('post_type' => bbp_get_reply_post_type(), 'order' => 'DESC', 'author' => $user_id2, 'post__in' => $allowed_posts));
return apply_filters('pg_get_user_replies_created', $query, $user_id);
}
示例2: test_bbp_get_user_id
/**
* @covers ::bbp_user_id
* @covers ::bbp_get_user_id
*/
public function test_bbp_get_user_id()
{
$int_value = $this->keymaster_userdata->ID;
$formatted_value = bbp_number_format($int_value);
// Integer.
$user_id = bbp_get_user_id($this->keymaster_id);
$this->assertSame($this->keymaster_id, $user_id);
// Output.
$this->expectOutputString($formatted_value);
bbp_user_id($this->keymaster_id);
}
示例3: printf
<div id="author-description">
<h1><?php
printf(__('About %s', 'bbpress'), bbp_get_displayed_user_field('display_name'));
?>
</h1>
<?php
bbp_displayed_user_field('description');
?>
</div><!-- #author-description -->
</div><!-- #entry-author-info -->
<?php
$user_id = bbp_get_user_id();
$curr_user_id = bbp_get_user_id('', false, true);
$items = get_user_meta($user_id, $key = 'purchased_items', $single = true);
if (current_user_can('manage_options') || $user_id == $curr_user_id && is_user_logged_in()) {
?>
<?php
if ($items) {
?>
<div id="purchase-details">
<h2 class="entry-title">Purchase Details</h2>
<div class="bbp-user-section">
<?php
foreach ($items as $item) {
?>
示例4: stachestack_bbp_get_user_favorites_link
/**
* User favorites link
*
* Return the link to make a topic favorite/remove a topic from
* favorites
*
* @since bbPress (r2652)
*
* @param mixed $args This function supports these arguments:
* - subscribe: Favorite text
* - unsubscribe: Unfavorite text
* - user_id: User id
* - topic_id: Topic id
* - before: Before the link
* - after: After the link
* @param int $user_id Optional. User id
* @param int $topic_id Optional. Topic id
* @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. See ajax_favorite()
* @uses bbp_get_user_id() To get the user id
* @uses current_user_can() If the current user can edit the user
* @uses bbp_get_topic_id() To get the topic id
* @uses bbp_is_user_favorite() To check if the topic is user's favorite
* @uses bbp_get_favorites_permalink() To get the favorites permalink
* @uses bbp_get_topic_permalink() To get the topic permalink
* @uses bbp_is_favorites() Is it the favorites page?
* @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the
* html, add args, remove args, user & topic id
* @return string User favorites link
*/
function stachestack_bbp_get_user_favorites_link($args = '', $user_id = 0, $wrap = true)
{
if (!bbp_is_favorites_active()) {
return false;
}
// Parse arguments against default values
$r = bbp_parse_args($args, array('favorite' => __('Favorite', 'bbpress'), 'favorited' => __('Favorited', 'bbpress'), 'user_id' => 0, 'topic_id' => 0, 'before' => '', 'after' => ''), 'get_user_favorites_link');
// Validate user and topic ID's
$user_id = bbp_get_user_id($r['user_id'], true, true);
$topic_id = bbp_get_topic_id($r['topic_id']);
if (empty($user_id) || empty($topic_id)) {
return false;
}
// No link if you can't edit yourself
if (!current_user_can('edit_user', (int) $user_id)) {
return false;
}
// Decide which link to show
$is_fav = bbp_is_user_favorite($user_id, $topic_id);
if (!empty($is_fav)) {
$text = $r['favorited'];
$query_args = array('action' => 'bbp_favorite_remove', 'topic_id' => $topic_id);
} else {
$text = $r['favorite'];
$query_args = array('action' => 'bbp_favorite_add', 'topic_id' => $topic_id);
}
// Create the link based where the user is and if the topic is
// already the user's favorite
if (bbp_is_favorites()) {
$permalink = bbp_get_favorites_permalink($user_id);
} elseif (bbp_is_single_topic() || bbp_is_single_reply()) {
$permalink = bbp_get_topic_permalink($topic_id);
} else {
$permalink = get_permalink();
}
$url = esc_url(wp_nonce_url(add_query_arg($query_args, $permalink), 'toggle-favorite_' . $topic_id));
$sub = $is_fav ? ' class="is-favorite"' : '';
$html = sprintf('%s<span id="favorite-%d" %s><a href="%s" class="btn btn-success btn-xs favorite-toggle" data-topic="%d">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after']);
// Initial output is wrapped in a span, ajax output is hooked to this
if (!empty($wrap)) {
$html = '<span id="favorite-toggle">' . $html . '</span>';
}
// Return the link
return apply_filters('bbp_get_user_favorites_link', $html, $r, $user_id, $topic_id);
}
示例5: bbp_get_user_last_posted
/**
* Return the raw value of teh last posted time.
*
* @since 2.1.0 bbPress (r3910)
*
* @param int $user_id User ID to retrieve value for
* @return mixed False if no user, time() format if exists
*/
function bbp_get_user_last_posted($user_id = 0)
{
// Validate user id
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
$time = get_user_option('_bbp_last_posted', $user_id);
return apply_filters('bbp_get_user_last_posted', $time, $user_id);
}
示例6: bbp_get_user_replies_created
/**
* Get the replies that a user created
*
* @since bbPress (r4225)
*
* @param int $user_id Optional. User id
* @uses bbp_get_user_id() To get the topic id
* @uses bbp_has_replies() To get the topics created by the user
* @return array|bool Results if the user has created topics, otherwise false
*/
function bbp_get_user_replies_created($user_id = 0)
{
// Validate user
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
// Try to get the topics
$query = bbp_has_replies(array('post_type' => array(bbp_get_topic_post_type(), bbp_get_reply_post_type()), 'post_parent' => 'any', 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'DESC', 'author' => $user_id, 'show_stickies' => false));
return apply_filters('bbp_get_user_replies_created', $query, $user_id);
}
示例7: bbp_title
/**
* Custom page title for bbPress pages
*
* @since bbPress (r2788)
*
* @param string $title Optional. The title (not used).
* @param string $sep Optional, default is '»'. How to separate the
* various items within the page title.
* @param string $seplocation Optional. Direction to display title, 'right'.
* @uses bbp_is_single_user() To check if it's a user profile page
* @uses bbp_is_single_user_edit() To check if it's a user profile edit page
* @uses bbp_is_user_home() To check if the profile page is of the current user
* @uses get_query_var() To get the user id
* @uses get_userdata() To get the user data
* @uses bbp_is_single_forum() To check if it's a forum
* @uses bbp_get_forum_title() To get the forum title
* @uses bbp_is_single_topic() To check if it's a topic
* @uses bbp_get_topic_title() To get the topic title
* @uses bbp_is_single_reply() To check if it's a reply
* @uses bbp_get_reply_title() To get the reply title
* @uses is_tax() To check if it's the tag page
* @uses get_queried_object() To get the queried object
* @uses bbp_is_single_view() To check if it's a view
* @uses bbp_get_view_title() To get the view title
* @uses apply_filters() Calls 'bbp_raw_title' with the title
* @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
* separator and separator location
* @return string The tite
*/
function bbp_title($title = '', $sep = '»', $seplocation = '')
{
// Title array
$new_title = array();
/** Archives **************************************************************/
// Forum Archive
if (bbp_is_forum_archive()) {
$new_title['text'] = bbp_get_forum_archive_title();
// Topic Archive
} elseif (bbp_is_topic_archive()) {
$new_title['text'] = bbp_get_topic_archive_title();
/** Edit ******************************************************************/
// Forum edit page
} elseif (bbp_is_forum_edit()) {
$new_title['text'] = bbp_get_forum_title();
$new_title['format'] = esc_attr__('Forum Edit: %s', 'bbpress');
// Topic edit page
} elseif (bbp_is_topic_edit()) {
$new_title['text'] = bbp_get_topic_title();
$new_title['format'] = esc_attr__('Topic Edit: %s', 'bbpress');
// Reply edit page
} elseif (bbp_is_reply_edit()) {
$new_title['text'] = bbp_get_reply_title();
$new_title['format'] = esc_attr__('Reply Edit: %s', 'bbpress');
// Topic tag edit page
} elseif (bbp_is_topic_tag_edit()) {
$new_title['text'] = bbp_get_topic_tag_name();
$new_title['format'] = esc_attr__('Topic Tag Edit: %s', 'bbpress');
/** Singles ***************************************************************/
// Forum page
} elseif (bbp_is_single_forum()) {
$new_title['text'] = bbp_get_forum_title();
$new_title['format'] = esc_attr__('Forum: %s', 'bbpress');
// Topic page
} elseif (bbp_is_single_topic()) {
$new_title['text'] = bbp_get_topic_title();
$new_title['format'] = esc_attr__('Topic: %s', 'bbpress');
// Replies
} elseif (bbp_is_single_reply()) {
$new_title['text'] = bbp_get_reply_title();
// Topic tag page
} elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag')) {
$new_title['text'] = bbp_get_topic_tag_name();
$new_title['format'] = esc_attr__('Topic Tag: %s', 'bbpress');
/** Users *****************************************************************/
// Profile page
} elseif (bbp_is_single_user()) {
// User is viewing their own profile
if (bbp_is_user_home()) {
$new_title['text'] = esc_attr_x('Your', 'User viewing his/her own profile', 'bbpress');
// User is viewing someone else's profile (so use their display name)
} else {
$new_title['text'] = sprintf(esc_attr_x("%s's", 'User viewing another users profile', 'bbpress'), get_userdata(bbp_get_user_id())->display_name);
}
// User topics created
if (bbp_is_single_user_topics()) {
$new_title['format'] = esc_attr__("%s Topics", 'bbpress');
// User rueplies created
} elseif (bbp_is_single_user_replies()) {
$new_title['format'] = esc_attr__("%s Replies", 'bbpress');
// User favorites
} elseif (bbp_is_favorites()) {
$new_title['format'] = esc_attr__("%s Favorites", 'bbpress');
// User subscriptions
} elseif (bbp_is_subscriptions()) {
$new_title['format'] = esc_attr__("%s Subscriptions", 'bbpress');
// User "home"
} else {
$new_title['format'] = esc_attr__("%s Profile", 'bbpress');
}
// Profile edit page
//.........这里部分代码省略.........
示例8: action_bbpress_button
/**
* Adds a 'Switch To' link to each member's profile page in bbPress.
*/
public function action_bbpress_button()
{
if (!($user = get_userdata(bbp_get_user_id()))) {
return;
}
if (!($link = self::maybe_switch_url($user))) {
return;
}
$link = add_query_arg(array('redirect_to' => urlencode(bbp_get_user_profile_url($user->ID))), $link);
?>
<ul id="user_switching_switch_to">
<li><a href="<?php
echo esc_url($link);
?>
"><?php
esc_html_e('Switch To', 'user-switching');
?>
</a></li>
</ul>
<?php
}
示例9: bbp_user_can_view_forum
/**
* Check if the user can access a specific forum
*
* @since 2.0.0 bbPress (r3127)
*
* @uses bbp_get_current_user_id()
* @uses bbp_get_forum_id()
* @uses bbp_allow_anonymous()
* @uses bbp_parse_args()
* @uses bbp_get_user_id()
* @uses current_user_can()
* @uses bbp_is_user_keymaster()
* @uses bbp_is_forum_public()
* @uses bbp_is_forum_private()
* @uses bbp_is_forum_hidden()
* @uses current_user_can()
* @uses apply_filters()
*
* @return bool
*/
function bbp_user_can_view_forum($args = array())
{
// Parse arguments against default values
$r = bbp_parse_args($args, array('user_id' => bbp_get_current_user_id(), 'forum_id' => bbp_get_forum_id(), 'check_ancestors' => false), 'user_can_view_forum');
// Validate parsed values
$user_id = bbp_get_user_id($r['user_id'], false, false);
$forum_id = bbp_get_forum_id($r['forum_id']);
$retval = false;
// User is a keymaster
if (!empty($user_id) && bbp_is_user_keymaster($user_id)) {
$retval = true;
// Forum is public, and user can read forums or is not logged in
} elseif (bbp_is_forum_public($forum_id, $r['check_ancestors'])) {
$retval = true;
// Forum is private, and user can see it
} elseif (bbp_is_forum_private($forum_id, $r['check_ancestors']) && user_can($user_id, 'read_private_forums')) {
$retval = true;
// Forum is hidden, and user can see it
} elseif (bbp_is_forum_hidden($forum_id, $r['check_ancestors']) && user_can($user_id, 'read_hidden_forums')) {
$retval = true;
}
return apply_filters('bbp_user_can_view_forum', $retval, $forum_id, $user_id);
}
示例10: bbps_envato_bbp_user_edit_additional
function bbps_envato_bbp_user_edit_additional($edit = true)
{
if (get_option('_bbps_envato_username', '') && get_option('_bbps_envato_api_key', '')) {
$envato_codes = get_user_meta(bbp_get_user_id(), 'envato_codes', true);
?>
<fieldset class="bbp-form">
<legend><?php
_e('Verified Purchases', 'bbpress');
?>
</legend>
<?php
if (is_array($envato_codes)) {
//print_r($envato_codes);
?>
<ul>
<?php
foreach ($envato_codes as $license_code => $license_data) {
?>
<li>
Purchase <?php
echo $license_data['item_name'];
?>
on <?php
echo $license_data['created_at'];
?>
with
username <?php
echo $license_data['buyer'];
?>
(<?php
echo $license_data['licence'];
?>
).
</li>
<?php
}
?>
</ul>
<?php
}
?>
<?php
if (true) {
?>
<p>Submit additional purchase codes here (<a
href="//dtbaker.net/admin/includes/plugin_envato/images/envato-license-code.gif" target="_blank">click
here</a> for help locating your item purchase code):</p>
<div class="form-group">
<input type="text" class="form-control" name="user_purchase_code" id="register_widget_purchase_code"
placeholder="Please paste your purchase code here">
</div>
<button type="submit" class="btn btn-default">Submit Purchase Code</button>
<?php
}
?>
</fieldset>
<?php
}
}
示例11: suggest_user
/**
* Ajax action for facilitating the topic and reply author auto-suggest
*
* @since bbPress (r5014)
*/
public function suggest_user()
{
// Try to get some users
$users_query = new WP_User_Query(array('search' => '*' . like_escape($_REQUEST['q']) . '*', 'fields' => array('ID', 'user_nicename'), 'search_columns' => array('ID', 'user_nicename', 'user_email'), 'orderby' => 'ID'));
// If we found some users, loop through and display them
if (!empty($users_query->results)) {
foreach ((array) $users_query->results as $user) {
printf(esc_html__('%s - %s', 'bbpress'), bbp_get_user_id($user->ID), bbp_get_user_nicename($user->ID, array('force' => $user->user_nicename)) . "\n");
}
}
die;
}
示例12: bbp_bump_user_reply_count
/**
* Bump the reply count for a user by a certain amount.
*
* @since 2.6.0 bbPress (r5309)
*
* @param int $user_id
* @param int $difference
* @uses bbp_get_user_reply_count() To get the users current reply count
* @uses bbp_set_user_reply_count() To set the users new reply count
*/
function bbp_bump_user_reply_count($user_id = 0, $difference = 1)
{
// Bail if no bump
if (empty($difference)) {
return false;
}
// Validate user ID
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
// Check meta for count, or query directly if not found
$count = bbp_get_user_reply_count($user_id, true);
if (empty($count)) {
$count = bbp_get_user_reply_count_raw($user_id);
}
$difference = (int) $difference;
$user_reply_count = (int) ($count + $difference);
// Add them up and filter them
$new_count = (int) apply_filters('bbp_bump_user_reply_count', $user_reply_count, $user_id, $difference, $count);
return bbp_update_user_reply_count($user_id, $new_count);
}
示例13: get_breadcrumb_leaf_markup
/**
* Adds the markup of the breadcrumb leaf
* @param string $object_id ID of the current query object
*
* @return string The HTML markup of the breadcrumb leaf
*/
private function get_breadcrumb_leaf_markup($object_type = '')
{
global $wp_query, $wp_locale;
switch ($object_type) {
case 'term':
$term = $wp_query->get_queried_object();
$title = $term->name;
break;
case 'year':
$title = esc_html(get_query_var('year'));
break;
case 'month':
$title = $wp_locale->get_month(get_query_var('monthnum'));
break;
case 'day':
$title = get_query_var('day');
break;
case 'author':
$user = $wp_query->get_queried_object();
$title = $user->display_name;
break;
case 'search':
$title = sprintf('%s %s', $this->search_prefix, esc_html(get_search_query()));
break;
case '404':
$title = $this->error_prefix;
break;
case 'bbpress_search':
$title = sprintf('%s %s', $this->search_prefix, urldecode(esc_html(get_query_var('bbp_search'))));
break;
case 'bbpress_user':
$current_user_id = bbp_get_user_id(0, true, false);
$current_user = get_userdata($current_user_id);
$title = $current_user->display_name;
break;
case 'events':
$title = tribe_get_events_title();
break;
default:
$title = get_the_title($this->post->ID);
break;
}
return sprintf('<span class="breadcrumb-leaf">%s</span>', $title);
}
示例14: action_bbpress_button
/**
* Adds a 'Switch To' link to each member's profile page in bbPress.
*
* @return null
*/
public function action_bbpress_button()
{
$id = bbp_get_user_id();
if (!($link = self::maybe_switch_url($id))) {
return;
}
$link = add_query_arg(array('redirect_to' => urlencode(bbp_get_user_profile_url($id))), $link);
?>
<ul>
<li><a href="<?php
echo $link;
?>
"><?php
_e('Switch To', 'user-switching');
?>
</a></li>
</ul>
<?php
}
示例15: bbpvotes_get_post_votes_log
function bbpvotes_get_post_votes_log($post_id = 0)
{
if (!($votes = bbpvotes_get_votes_for_post($post_id))) {
return;
}
$r = "\n\n" . '<div id="bbpvotes-post-votes-log-' . esc_attr($post_id) . '" class="bbpvotes-post-votes-log">' . "\n\n";
if (!bbpvotes()->options['anonymous_vote']) {
foreach ($votes as $user_id => $score) {
$user_id = bbp_get_user_id($user_id);
if (!($user = get_userdata($user_id))) {
continue;
}
if ($score > 0) {
$title = sprintf(esc_html__('%1$s voted up', 'bbpvotes'), $user->display_name);
$icon = '<i class="bbpvotes-avatar-icon-vote bbpvotes-avatar-icon-plus fa fa-plus-square"></i>';
} else {
$title = sprintf(esc_html__('%1$s voted down', 'bbpvotes'), $user->display_name);
$icon = '<i class="bbpvotes-avatar-icon-vote bbpvotes-avatar-icon-minus fa fa-minus-square"></i>';
}
$user_avatar = get_avatar($user_id, 30);
$user_vote_link = sprintf('<a title="%1$s" href="%2$s">%3$s</a>', $title, esc_url(bbp_get_user_profile_url($user_id)), $user_avatar . $icon);
$r .= apply_filters('bbpvotes_get_post_votes_log_user', $user_vote_link, $user_id, $score);
}
} else {
$votes_str = array();
if ($votes_up = bbpvotes_get_votes_up_for_post($post_id)) {
$votes_up_count = count($votes_up);
$votes_up_count_display = bbpvotes_number_format($votes_up_count);
$votes_str[] = sprintf(_n('%s vote up', '%s votes up', $votes_up_count), '<span class="bbpvotes-score">' . $votes_up_count_display . '</span>');
}
if ($votes_down = bbpvotes_get_votes_down_for_post($post_id)) {
$votes_down_count = count($votes_down);
$votes_down_count_display = bbpvotes_number_format($votes_down_count);
$votes_str[] = sprintf(_n('%s vote down', '%s votes down', $votes_down_count), '<span class="bbpvotes-score">' . $votes_down_count_display . '</span>');
}
$votes_str = implode(' ' . __('and', 'bbpvotes') . ' ', $votes_str);
$r .= sprintf(__('This reply has received %1$s.', 'bbpvotes'), $votes_str);
}
$r .= "\n" . '</div>' . "\n\n";
return apply_filters('bbpvotes_get_post_votes_log', $r, $post_id);
}