コード例 #1
0
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
0
ファイル: user.php プロジェクト: CompositeUK/clone.bbPress
 /**
  * @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
0
		<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
0
/**
 * 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
0
ファイル: options.php プロジェクト: joeyblake/bbpress
/**
 * 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
0
ファイル: functions.php プロジェクト: hscale/webento
/**
 * 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
0
ファイル: template.php プロジェクト: danielcoats/schoolpress
/**
 * Custom page title for bbPress pages
 *
 * @since bbPress (r2788)
 *
 * @param string $title Optional. The title (not used).
 * @param string $sep Optional, default is '&raquo;'. 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 = '&raquo;', $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
    } elseif (bbp_is_single_user_edit()) {
        // Current user
        if (bbp_is_user_home_edit()) {
            $new_title['text'] = esc_attr__('Edit Your Profile', 'bbpress');
            // Other user
        } else {
            $new_title['text'] = get_userdata(bbp_get_user_id())->display_name;
            $new_title['format'] = esc_attr__("Edit %s's Profile", 'bbpress');
        }
        /** Views *****************************************************************/
        // Views
    } elseif (bbp_is_single_view()) {
        $new_title['text'] = bbp_get_view_title();
        $new_title['format'] = esc_attr__('View: %s', 'bbpress');
        /** Search ****************************************************************/
        // Search
    } elseif (bbp_is_search()) {
        $new_title['text'] = bbp_get_search_title();
    }
    // This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
    $new_title = apply_filters('bbp_raw_title_array', $new_title);
    // Set title array defaults
    $new_title = bbp_parse_args($new_title, array('text' => $title, 'format' => '%s'), 'title');
    // Get the formatted raw title
    $new_title = sprintf($new_title['format'], $new_title['text']);
    // Filter the raw title
    $new_title = apply_filters('bbp_raw_title', $new_title, $sep, $seplocation);
    // Compare new title with original title
    if ($new_title === $title) {
        return $title;
    }
    // Temporary separator, for accurate flipping, if necessary
    $t_sep = '%WP_TITILE_SEP%';
    $prefix = '';
    if (!empty($new_title)) {
        $prefix = " {$sep} ";
    }
    // sep on right, so reverse the order
    if ('right' === $seplocation) {
        $new_title_array = array_reverse(explode($t_sep, $new_title));
        $new_title = implode(" {$sep} ", $new_title_array) . $prefix;
        // sep on left, do not reverse
    } else {
        $new_title_array = explode($t_sep, $new_title);
        $new_title = $prefix . implode(" {$sep} ", $new_title_array);
    }
    // Filter and return
    return apply_filters('bbp_title', $new_title, $sep, $seplocation);
}
コード例 #8
0
    /**
     * 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&nbsp;To', 'user-switching');
        ?>
</a></li>
		</ul>
		<?php 
    }
コード例 #9
0
/**
 * 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
0
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
0
ファイル: admin.php プロジェクト: danielcoats/schoolpress
 /**
  * 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
0
/**
 * 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
0
 /**
  * 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
0
ファイル: user-switching.php プロジェクト: roycocup/enclothed
    /**
     * 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&nbsp;To', 'user-switching');
        ?>
</a></li>
		</ul>
		<?php 
    }
コード例 #15
0
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);
}
コード例 #16
0
ファイル: bbp-user-functions.php プロジェクト: hscale/webento
/**
 * Return a user's main 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);
    if (empty($user_id)) {
        return false;
    }
    // Get userdata
    $user = get_userdata($user_id);
    // Get the user's main role
    $role = isset($user->roles) ? array_shift($user->roles) : bbp_get_anonymous_role();
    return apply_filters('bbp_get_user_role', $role, $user_id, $user);
}
コード例 #17
0
/**
 * Can a user moderate a forum?
 *
 * @since 2.6.0 bbPress (r5834)
 *
 * @param int $user_id User id.
 * @param int $forum_id Forum id.
 * @uses bbp_get_user_id()
 * @uses bbp_get_forum_id()
 * @uses bbp_get_moderator_forum_ids()
 * @uses apply_filters() Calls 'bbp_is_user_forum_moderator' with the forums
 *
 * @return bool Return true if user is moderator of forum
 */
function bbp_is_user_forum_moderator($user_id = 0, $forum_id = 0)
{
    // Assume user cannot moderate the forum.
    $retval = false;
    // Validate user ID - fallback to current user if no ID passed.
    $user_id = bbp_get_user_id($user_id, false, !empty($user_id));
    $forum_id = bbp_get_forum_id($forum_id);
    $forum_ids = array();
    // Only check if per-forum moderation is enabled
    if (bbp_allow_forum_mods()) {
        // Get forums the user can moderate.
        $forum_ids = bbp_get_moderator_forum_ids($user_id);
        // Is this forum ID in the users array of forum IDs?
        if (!empty($forum_ids)) {
            $retval = in_array($forum_id, $forum_ids);
        }
    }
    return (bool) apply_filters('bbp_is_user_forum_moderator', $retval, $user_id, $forum_id, $forum_ids);
}
コード例 #18
0
ファイル: topbar.php プロジェクト: kanawanzx/support_forum
?>
<div id="topbar">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-md-8">
                <div class="as-text-topbar-header">
                    <div class="time-zone-wrapper">      
                        <span class="iva_visitor_time"><span class="iva-time"><strong>Your Time:&nbsp;</strong></span><span class="time-zone-visitor-icon dslc-icon "></span> <span id="your_time">11:40:47</span></span>
                        &nbsp;-&nbsp;
                        <span class="iva_support_time"><span class="iva-time"><strong>Our Time:&nbsp;</strong></span><span class="time-zone-support-icon dslc-icon "></span> <span id="our_time">10:10:47</span></span>
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-md-4">
                <div class="as-group-button-topbar">
                    <?php 
if (is_user_logged_in()) {
    echo '<a href="' . bbp_get_user_profile_edit_url(bbp_get_user_id('', false, true)) . '" class="as-btn-style as-bg-color">Edit Profile</a>';
    echo '<a href="' . wp_logout_url($redirect = home_url()) . '" class="as-btn-style">Logout</a>';
} else {
    echo '<a href="' . wp_login_url($redirect = home_url(), $force_reauth = false) . '" class="as-btn-style">Login</a>';
    echo '<a href="' . wp_login_url() . '?action=register" class="as-btn-style as-bg-color">Register</a>';
}
?>
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
コード例 #19
0
ファイル: bbpress.php プロジェクト: luskyj89/mt-wordpress
<?php

get_header();
$cb_user_page = NULL;
global $bb_current_user;
$cb_breadcrumbs = ot_get_option('cb_breadcrumbs', 'on');
$cb_theme_style = ot_get_option('cb_theme_style', 'cb_boxed');
$cb_bbpress_sidebar = ot_get_option('cb_bbpress_sidebar', 'sidebar');
$cb_bbpress_global_color = ot_get_option('cb_bbpress_global_color', '#eb9812');
$cb_current_user = bbp_get_user_id();
$cb_forum_id = bbp_get_forum_id();
$cb_title = get_the_title();
if (bbp_is_single_user() == true || bbp_is_favorites() == true) {
    $cb_title = '<h1 id="cb-cat-title"><span>' . __('Member', 'cubell') . ' <i class="icon-long-arrow-right"></i></span> ' . get_the_title() . '</h1>';
    $cb_user_page = 'cb-author-page ';
}
$cb_sidebar_position = NULL;
if ($cb_bbpress_sidebar == 'sidebar_left') {
    $cb_sidebar_position = ' cb-sidebar-left ';
} elseif ($cb_bbpress_sidebar == 'nosidebar') {
    $cb_sidebar_position = ' cb-full-width';
}
?>
                
				<div id="cb-content" class="<?php 
if ($cb_user_page != NULL) {
    echo $cb_user_page;
}
?>
wrap clearfix">
コード例 #20
0
ファイル: bbp-user-template.php プロジェクト: rmccue/bbPress
/**
 * Check if the user can access a specific forum
 *
 * @since 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 is_super_admin()
 * @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 = '')
{
    // Default arguments
    $defaults = array('user_id' => bbp_get_current_user_id(), 'forum_id' => bbp_get_forum_id(), 'check_ancestors' => false);
    $r = bbp_parse_args($args, $defaults, 'user_can_view_forum');
    extract($r);
    // Validate parsed values
    $user_id = bbp_get_user_id($user_id, false, false);
    $forum_id = bbp_get_forum_id($forum_id);
    $retval = false;
    // User is a super admin
    if (is_super_admin()) {
        $retval = true;
    } elseif (bbp_is_forum_public($forum_id, $check_ancestors)) {
        $retval = true;
    } elseif (bbp_is_forum_private($forum_id, $check_ancestors) && current_user_can('read_private_forums')) {
        $retval = true;
    } elseif (bbp_is_forum_hidden($forum_id, $check_ancestors) && current_user_can('read_hidden_forums')) {
        $retval = true;
    }
    return apply_filters('bbp_user_can_view_forum', $retval, $forum_id, $user_id);
}
コード例 #21
0
/**
 * Update the revision log of the topic
 *
 * @since bbPress (r2782)
 *
 * @param mixed $args Supports these args:
 *  - topic_id: Topic id
 *  - author_id: Author id
 *  - reason: Reason for editing
 *  - revision_id: Revision id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_user_id() To get the user id
 * @uses bbp_format_revision_reason() To format the reason
 * @uses bbp_get_topic_raw_revision_log() To get the raw topic revision log
 * @uses update_post_meta() To update the topic revision log meta
 * @return mixed False on failure, true on success
 */
function bbp_update_topic_revision_log($args = '')
{
    $defaults = array('reason' => '', 'topic_id' => 0, 'author_id' => 0, 'revision_id' => 0);
    $r = bbp_parse_args($args, $defaults, 'update_topic_revision_log');
    extract($r);
    // Populate the variables
    $reason = bbp_format_revision_reason($reason);
    $topic_id = bbp_get_topic_id($topic_id);
    $author_id = bbp_get_user_id($author_id, false, true);
    $revision_id = (int) $revision_id;
    // Get the logs and append the new one to those
    $revision_log = bbp_get_topic_raw_revision_log($topic_id);
    $revision_log[$revision_id] = array('author' => $author_id, 'reason' => $reason);
    // Finally, update
    return update_post_meta($topic_id, '_bbp_revision_log', $revision_log);
}
コード例 #22
0
ファイル: topbar.php プロジェクト: CloouCom/Supportte
<?php

/** Top Bar */
?>

<div id="topbar">
	<div class="inner">
		
		<div class="left">
			Welcome to Aquagraphite Support Forum :)
		</div>

		<div class="right">
			<?php 
if (is_user_logged_in()) {
    echo '<a href="' . bbp_get_user_profile_edit_url(bbp_get_user_id('', false, true)) . '">Edit Profile</a> or ';
    echo '<a href="' . wp_logout_url($redirect = home_url()) . '">Logout</a>';
} else {
    echo '<a href="' . wp_login_url($redirect = home_url(), $force_reauth = false) . '">Login</a> or ';
    echo '<a href="' . wp_login_url() . '?action=register">Register</a>';
}
?>
		</div>

		<div class="clearfix"></div>

	</div>
</div>
コード例 #23
0
/**
 * Does a user have a profile for the current site
 *
 * @since bbPress (r4362)
 *
 * @param int $user_id User ID to check
 * @param int $blog_id Blog ID to check
 *
 * @uses bbp_get_user_id() To verify the user ID
 * @uses get_userdata() To get the user's data
 * @uses bbp_is_user_keymaster() To determine if user can see inactive users
 * @uses bbp_is_user_inactive() To check if user is spammer or deleted
 * @uses apply_filters() To allow override of this functions result
 *
 * @return boolean Whether or not the user has a profile on this blog_id
 */
function bbp_user_has_profile($user_id = 0)
{
    // Assume every user has a profile
    $retval = true;
    // Validate user ID, default to displayed or current user
    $user_id = bbp_get_user_id($user_id, true, true);
    // Try to get this user's data
    $user = get_userdata($user_id);
    // No user found, return false
    if (empty($user)) {
        $retval = false;
        // User is inactive, and current user is not a keymaster
    } elseif (!bbp_is_user_keymaster() && bbp_is_user_inactive($user->ID)) {
        $retval = false;
    }
    // Filter and return
    return (bool) apply_filters('bbp_show_user_profile', $retval, $user_id);
}
function gpbbp_profile_redirect()
{
    if (bbp_is_single_user()) {
        $directory_url = '/directory/user';
        $user_id = bbp_get_user_id();
        $user_profile_url = home_url() . $directory_url . '/' . $user_id;
        wp_redirect($user_profile_url);
        exit;
    }
}
コード例 #25
0
/**
 * Custom page title for bbPress pages
 *
 * @since bbPress (r2788)
 *
 * @param string $title Optional. The title (not used).
 * @param string $sep Optional, default is '&raquo;'. 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 = '&raquo;', $seplocation = '')
{
    // Store original title to compare
    $_title = $title;
    /** Archives **************************************************************/
    // Forum Archive
    if (bbp_is_forum_archive()) {
        $title = bbp_get_forum_archive_title();
        // Topic Archive
    } elseif (bbp_is_topic_archive()) {
        $title = bbp_get_topic_archive_title();
        /** Singles ***************************************************************/
        // Forum page
    } elseif (bbp_is_single_forum()) {
        $title = sprintf(__('Forum: %s', 'bbpress'), bbp_get_forum_title());
        // Topic page
    } elseif (bbp_is_single_topic()) {
        $title = sprintf(__('Topic: %s', 'bbpress'), bbp_get_topic_title());
        // Replies
    } elseif (bbp_is_single_reply()) {
        $title = bbp_get_reply_title();
        // Topic tag page (or edit)
    } elseif (bbp_is_topic_tag() || bbp_is_topic_tag_edit() || get_query_var('bbp_topic_tag')) {
        $term = get_queried_object();
        $title = sprintf(__('Topic Tag: %s', 'bbpress'), $term->name);
        /** Users *****************************************************************/
        // Profile page
    } elseif (bbp_is_single_user()) {
        // Current users profile
        if (bbp_is_user_home()) {
            $title = __('Your Profile', 'bbpress');
            // Other users profile
        } else {
            $userdata = get_userdata(bbp_get_user_id());
            $title = sprintf(__('%s\'s Profile', 'bbpress'), $userdata->display_name);
        }
        // Profile edit page
    } elseif (bbp_is_single_user_edit()) {
        // Current users profile
        if (bbp_is_user_home_edit()) {
            $title = __('Edit Your Profile', 'bbpress');
            // Other users profile
        } else {
            $userdata = get_userdata(bbp_get_user_id());
            $title = sprintf(__('Edit %s\'s Profile', 'bbpress'), $userdata->display_name);
        }
        /** Views *****************************************************************/
        // Views
    } elseif (bbp_is_single_view()) {
        $title = sprintf(__('View: %s', 'bbpress'), bbp_get_view_title());
    }
    // Filter the raw title
    $title = apply_filters('bbp_raw_title', $title, $sep, $seplocation);
    // Compare new title with original title
    if ($title == $_title) {
        return $title;
    }
    // Temporary separator, for accurate flipping, if necessary
    $t_sep = '%WP_TITILE_SEP%';
    $prefix = '';
    if (!empty($title)) {
        $prefix = " {$sep} ";
    }
    // sep on right, so reverse the order
    if ('right' == $seplocation) {
        $title_array = explode($t_sep, $title);
        $title_array = array_reverse($title_array);
        $title = implode(" {$sep} ", $title_array) . $prefix;
        // sep on left, do not reverse
    } else {
        $title_array = explode($t_sep, $title);
        $title = $prefix . implode(" {$sep} ", $title_array);
    }
    // Filter and return
    return apply_filters('bbp_title', $title, $sep, $seplocation);
}
コード例 #26
0
function st_bbp_get_user_topics_started($user_id = 0, $limit = 3, $max_num_pages = 1)
{
    // Validate user
    $user_id = bbp_get_user_id($user_id);
    if (empty($user_id)) {
        return false;
    }
    // Query defaults
    $default_query = array('author' => $user_id, 'show_stickies' => false, 'order' => 'DESC', 'posts_per_page' => $limit, 'max_num_pages' => $max_num_pages);
    // Try to get the topics
    $query = bbp_has_topics($default_query);
    if (empty($query)) {
        return false;
    }
    return apply_filters('bbp_get_user_topics_started', $query, $user_id);
}
コード例 #27
0
/**
 * Update the revision log of the topic
 *
 * @since bbPress (r2782)
 *
 * @param mixed $args Supports these args:
 *  - topic_id: Topic id
 *  - author_id: Author id
 *  - reason: Reason for editing
 *  - revision_id: Revision id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_format_revision_reason() To format the reason
 * @uses bbp_get_topic_raw_revision_log() To get the raw topic revision log
 * @uses update_post_meta() To update the topic revision log meta
 * @return mixed False on failure, true on success
 */
function bbp_update_topic_revision_log($args = '')
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('reason' => '', 'topic_id' => 0, 'author_id' => 0, 'revision_id' => 0), 'update_topic_revision_log');
    // Populate the variables
    $r['reason'] = bbp_format_revision_reason($r['reason']);
    $r['topic_id'] = bbp_get_topic_id($r['topic_id']);
    $r['author_id'] = bbp_get_user_id($r['author_id'], false, true);
    $r['revision_id'] = (int) $r['revision_id'];
    // Get the logs and append the new one to those
    $revision_log = bbp_get_topic_raw_revision_log($r['topic_id']);
    $revision_log[$r['revision_id']] = array('author' => $r['author_id'], 'reason' => $r['reason']);
    // Finally, update
    return update_post_meta($r['topic_id'], '_bbp_revision_log', $revision_log);
}
コード例 #28
0
ファイル: functions.php プロジェクト: sdh100shaun/pantheon
/**
 * 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' => bbp_get_reply_post_type(), 'order' => 'DESC', 'author' => $user_id));
    return apply_filters('bbp_get_user_replies_created', $query, $user_id);
}
コード例 #29
0
ファイル: admin.php プロジェクト: sdh100shaun/pantheon
 /**
  * Ajax action for facilitating the topic and reply author auto-suggest
  *
  * @since bbPress (r5014)
  */
 public function suggest_user()
 {
     global $wpdb;
     // Bail early if no request
     if (empty($_REQUEST['q'])) {
         wp_die('0');
     }
     // Bail if user cannot moderate - only moderators can change authorship
     if (!current_user_can('moderate')) {
         wp_die('0');
     }
     // Check the ajax nonce
     check_ajax_referer('bbp_suggest_user_nonce');
     // Try to get some users
     $users_query = new WP_User_Query(array('search' => '*' . $wpdb->esc_like($_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;
 }
コード例 #30
0
ファイル: counts.php プロジェクト: joeyblake/bbpress
 /**
  * @covers ::bbp_user_id
  * @covers ::bbp_get_user_id
  */
 public function test_bbp_get_user_id()
 {
     $u = $this->factory->user->create();
     $user_id = bbp_get_user_id($u);
     $this->assertSame($u, $user_id);
 }