Ejemplo n.º 1
0
?>

	<?php 
if (post_password_required()) {
    ?>

		<?php 
    bbp_get_template_part('form', 'protected');
    ?>

	<?php 
} else {
    ?>

		<?php 
    bbp_single_forum_description(array('before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">' . bbp_get_forum_subscription_link()));
    ?>

		<?php 
    if (bbp_has_forums()) {
        ?>

			<?php 
        bbp_get_template_part('loop', 'forums');
        ?>

		<?php 
    }
    ?>

		<?php 
Ejemplo n.º 2
0
 /**
  * AJAX handler to Subscribe/Unsubscribe a user from a forum
  *
  * @since bbPress (r5155)
  *
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_is_user_logged_in() To check if user is logged in
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses current_user_can() To check if the current user can edit the user
  * @uses bbp_get_forum() To get the forum
  * @uses wp_verify_nonce() To verify the nonce
  * @uses bbp_is_user_subscribed() To check if the forum is in user's subscriptions
  * @uses bbp_remove_user_subscriptions() To remove the forum from user's subscriptions
  * @uses bbp_add_user_subscriptions() To add the forum from user's subscriptions
  * @uses bbp_ajax_response() To return JSON
  */
 public function ajax_forum_subscription()
 {
     // Bail if subscriptions are not active
     if (!bbp_is_subscriptions_active()) {
         bbp_ajax_response(false, __('Subscriptions are no longer active.', 'bbpress'), 300);
     }
     // Bail if user is not logged in
     if (!is_user_logged_in()) {
         bbp_ajax_response(false, __('Please login to subscribe to this forum.', 'bbpress'), 301);
     }
     // Get user and forum data
     $user_id = bbp_get_current_user_id();
     $id = intval($_POST['id']);
     // Bail if user cannot add favorites for this user
     if (!current_user_can('edit_user', $user_id)) {
         bbp_ajax_response(false, __('You do not have permission to do this.', 'bbpress'), 302);
     }
     // Get the forum
     $forum = bbp_get_forum($id);
     // Bail if forum cannot be found
     if (empty($forum)) {
         bbp_ajax_response(false, __('The forum could not be found.', 'bbpress'), 303);
     }
     // Bail if user did not take this action
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'toggle-subscription_' . $forum->ID)) {
         bbp_ajax_response(false, __('Are you sure you meant to do that?', 'bbpress'), 304);
     }
     // Take action
     $status = bbp_is_user_subscribed($user_id, $forum->ID) ? bbp_remove_user_subscription($user_id, $forum->ID) : bbp_add_user_subscription($user_id, $forum->ID);
     // Bail if action failed
     if (empty($status)) {
         bbp_ajax_response(false, __('The request was unsuccessful. Please try again.', 'bbpress'), 305);
     }
     // Put subscription attributes in convenient array
     $attrs = array('forum_id' => $forum->ID, 'user_id' => $user_id);
     // Action succeeded
     bbp_ajax_response(true, bbp_get_forum_subscription_link($attrs, $user_id, false), 200);
 }
Ejemplo n.º 3
0
/**
 * Output the forum subscription link
 *
 * @since bbPress (r5156)
 *
 * @uses bbp_get_forum_subscription_link()
 */
function bbp_forum_subscription_link($args = array())
{
    echo bbp_get_forum_subscription_link($args);
}