Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 9,826 through 9,850 (of 32,511 total)
  • Author
    Search Results
  • #156427
    t3_rrY
    Participant

    Ok thanks very much for your reply and sharing your code; any idea on the use of HTML template for BBp notification?

    #156426
    Nicolas Korobochkin
    Participant

    bbPress have two types of notifications: new message in topic or new topic in forum. Functions that sends messages in bbpress/includes/common/functions.php. You can’t redeclare they. You need to remove default functions and add your custom one. Here is my working code for armyofselenagomez.com wich sends emails via external SMTP server (like Mandrill. but I use Yandex, like Gmail but in Russia). Be careful with priorities and numbers of arguments to pass.

    Logis of process:

    1. User leave a message or create a topic.
    2. Create single wp-crone task which create messages and send it.

    Positive sides of this solution: Emails sends per user (not 1 email per 100000 users like in bbPress by default). Site work faster because emails send via cron, not immediately. I dont store emails or messages to send in DB, just topic ID. Emails sends via SMTP server (not just PHP Mailer or wp_mail()).

    <?php
    function selena_network_bbp_init () {
    	/*
    	 * Оповещание о новых ответах в темах на форуме
    	 * 1. Удаляем дефолтную оповещалку.
    	 * 2. Добавляем свою оповещалку, которая создает крон-задачу.
    	 * 3. Экшн фильтр задачи, который создает письма и отправляет их.
    	 *
    	 * Функции находятся в файле
    	 * bbpress/includes/common/functions.php
    	 */
    	remove_action ('bbp_new_reply', 'bbp_notify_subscribers', 11);
    	add_action ('bbp_new_reply', 'selena_network_bbp_notify_subscribers', 11, 5);
    	add_action ('selena_network_bbp_notify_subscribers_cron', 'selena_network_bbp_notify_subscribers_callback', 10, 5);
    
    	/*
    	 * Оповещения о создании новых тем на форуме
    	 * 1. Удаляем дефолтную оповещалку.
    	 * 2. Добавляем свою оповещалку, которая создает крон-задачу.
    	 * 3. Экшн для задачи, который будет запускать крон (создает письма и отправляет их).
    	 *
    	 * Функции находятся в файле
    	 * bbpress/includes/common/functions.php
    	 */
    	remove_action ('bbp_new_topic', 'bbp_notify_forum_subscribers', 11);
    	add_action ('bbp_new_topic', 'selena_network_bbp_notify_forum_subscribers', 11, 4);
    	add_action ('selena_network_bbp_notify_forum_subscribers_cron', 'selena_network_bbp_notify_forum_subscribers_callback', 10, 4);
    }
    add_action ('bbp_init', 'selena_network_bbp_init', 99);
    <?php
    function selena_network_bbp_notify_subscribers (
    	$reply_id = 0,
    	$topic_id = 0,
    	$forum_id = 0,
    	$anonymous_data = false,
    	$reply_author = 0
    ) {
    	wp_schedule_single_event (
    		time (),
    		'selena_network_bbp_notify_subscribers_cron',
    		array (
    			$reply_id,
    			$topic_id,
    			$forum_id,
    			$anonymous_data,
    			$reply_author
    		)
    	);
    
    	return true;
    }
    
    function selena_network_bbp_notify_subscribers_callback (
    	$reply_id,
    	$topic_id,
    	$forum_id,
    	$anonymous_data,
    	$reply_author
    ) {
    	// Bail if subscriptions are turned off
    	if ( !bbp_is_subscriptions_active() ) {
    		return false;
    	}
    
    	$reply_id = bbp_get_reply_id( $reply_id );
    	$topic_id = bbp_get_topic_id( $topic_id );
    	$forum_id = bbp_get_forum_id( $forum_id );
    
    	// Bail if topic is not published
    	if ( !bbp_is_topic_published( $topic_id ) ) {
    		return false;
    	}
    
    	// Bail if reply is not published
    	if ( !bbp_is_reply_published( $reply_id ) ) {
    		return false;
    	}
    
    	// User Subscribers
    	$user_ids = bbp_get_topic_subscribers( $topic_id, true );
    	if ( empty( $user_ids ) ) {
    		return false;
    	}
    
    	// Poster name
    	$reply_author_name = bbp_get_reply_author_display_name( $reply_id );
    
    	// Remove filters from reply content and topic title to prevent content
    	// from being encoded with HTML entities, wrapped in paragraph tags, etc...
    	remove_all_filters( 'bbp_get_reply_content' );
    	remove_all_filters( 'bbp_get_topic_title'   );
    
    	// Strip tags from text and setup mail data
    	$topic_title   = strip_tags( bbp_get_topic_title( $topic_id ) );
    	$reply_url     = bbp_get_reply_url( $reply_id );
    
    	$subject = sprintf(
    		_x (
    			'%1$s wrote new comment in “%2$s”',
    			'%1$s = Name of user who create comment
    %2$s = Topic title in which user leave a comment',
    			'selena_network'),
    		$reply_author_name,
    		$topic_title
    	);
    	if (empty ($subject)) {
    		return;
    	}
    
    	// Loop through users
    	foreach ( (array) $user_ids as $user_id ) {
    
    		// Don't send notifications to the person who made the post
    		if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author ) {
    			continue;
    		}
    
    		// For plugins to filter messages per reply/topic/user
    		$message = sprintf (
    			_x (
    '%1$s wrote new comment in conversation “%2$s” %3$s.
    
    +
    Notification settings → %4$s.
    Send email at %5$s or respond on that letter if you have a questions.',
    			'%1$s = Reply author name
    %2$s = Topic title
    %3$s = Reply URL to this topic
    %4$s = Manage subscribe settings link
    %5$s = Admin email',
    			'selena_network'
    			),
    
    			$reply_author_name,
    			$topic_title,
    			$reply_url,
    			bbp_get_subscriptions_permalink ($user_id),
    			get_option ('admin_email')
    		);
    
    		if ( empty( $message ) ) {
    			continue;
    		}
    
    		wp_mail (
    			get_userdata( $user_id )->user_email,
    			$subject,
    			$message
    		);
    	}
    
    	return true;
    }
    
    /* Новая тема на форуме */
    function selena_network_bbp_notify_forum_subscribers (
    	$topic_id = 0,
    	$forum_id = 0,
    	$anonymous_data = false,
    	$topic_author = 0
    ) {
    	wp_schedule_single_event (
    		time (),
    		'selena_network_bbp_notify_forum_subscribers_cron',
    		array (
    			$topic_id,
    			$forum_id,
    			$anonymous_data,
    			$topic_author
    		)
    	);
    
    	return true;
    }
    function selena_network_bbp_notify_forum_subscribers_callback (
    	$topic_id,
    	$forum_id,
    	$anonymous_data,
    	$topic_author
    ) {
    	// Bail if subscriptions are turned off
    	if ( !bbp_is_subscriptions_active() ) {
    		return false;
    	}
    
    	$topic_id = bbp_get_topic_id( $topic_id );
    	$forum_id = bbp_get_forum_id( $forum_id );
    
    	// Get topic subscribers and bail if empty
    	$user_ids = bbp_get_forum_subscribers( $forum_id, true );
    	if ( empty( $user_ids ) ) {
    		return false;
    	}
    
    	// Bail if topic is not published
    	if ( ! bbp_is_topic_published( $topic_id ) ) {
    		return false;
    	}
    
    	// Poster name
    	$topic_author_name = bbp_get_topic_author_display_name( $topic_id );
    
    	// Remove filters from reply content and topic title to prevent content
    	// from being encoded with HTML entities, wrapped in paragraph tags, etc...
    	remove_all_filters( 'bbp_get_topic_content' );
    	remove_all_filters( 'bbp_get_topic_title'   );
    
    	// Strip tags from text and setup mail data
    	$topic_title   = strip_tags( bbp_get_topic_title( $topic_id ) );
    	$forum_title   = strip_tags( bbp_get_forum_title( $forum_id ) );
    	$topic_url     = get_permalink( $topic_id );
    
    	// For plugins to filter titles per reply/topic/user
    	//$subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id );
    	$subject = sprintf (
    		_x (
    			'%1$s created new conversation “%2$s”',
    			'%1$s = Topic author name who create new new topic
    %2$s = Topic title',
    			'selena_network'
    		),
    		$topic_author_name,
    		$topic_title
    	);
    	if ( empty( $subject ) ) {
    		return;
    	}
    
    	// Loop through users
    	foreach ( (array) $user_ids as $user_id ) {
    
    		// Don't send notifications to the person who made the post
    		if ( !empty( $topic_author ) && (int) $user_id === (int) $topic_author ) {
    			continue;
    		}
    
    		// For plugins to filter messages per reply/topic/user
    		$message = sprintf( _x( '%1$s created new conversation “%2$s” in the forum “%3$s” %4$s.
    
    +
    Notification settings → %5$s.
    Send email at %6$s or respond on that letter if you have a questions.',
    			'%1$s = Topic author name
    %2$s = Created topic title
    %3$s = Forum title in wich topic created
    %4$s = Link to brand new topic
    %5$s = URL to manage user subscribtions
    %6$s = Admin email',
    			'selena_network' ),
    
    			$topic_author_name, // 1
    			$topic_title, // 2
    			$forum_title, // 3
    			$topic_url, // 4
    			bbp_get_subscriptions_permalink ($user_id), // 5
    			get_option ('admin_email') // 6
    		);
    
    		if ( empty( $message ) ) {
    			continue;
    		}
    
    		// Send notification email
    		wp_mail (
    			get_userdata( $user_id )->user_email,
    			$subject,
    			$message
    		);
    	}
    
    	return true;
    }
    ?>
    #156412

    In reply to: Template

    Robkk
    Moderator

    1. heres a pretty good tutorial in the docs to style your bbPress forums with some CSS

    bbPress Styling Crib

    2. if your talking about maybe downloading some already styled templates there is none, i think bbPress standalone had this but theme compatibility makes giving away already styled templates pretty tough.

    if you actually want to see what users could create with bbPress check out some of the sites listed here

    bbpress.org/about/examples/

    3. as long as you follow this link

    codex.bbpress.org/theme-compatibility/

    you can use the templates to customize bbPress forums to your liking.

    also checking the rest of the docs wouldnt be bad too.

    codex.bbpress.org/

    #156398
    Robkk
    Moderator

    the way bbPress outputs the login page bugs me, a lot. What I am trying to do is add a login box to my layout, when I did – I found it added a list and a horrible fieldset around the whole thing. This doesn’t work with my design at all.

    are you using the shortcode [bbp-login] ??

    you should use that shortcode if not.

    more shortcodes supplied with bbPress that you can use.

    https://codex.bbpress.org/shortcodes/

    I found there is no template readily available to just change. Really?

    yes there is its called form-user-login.php

    So, it seems all I can do is hack away at the core code, which will all be reverted once a new version comes around.

    dont do that

    #156388
    Robin W
    Moderator

    It bugs me as well.

    Two solutions I have documented

    Layout and functionality – Examples you can use

    Layout and functionality – Examples you can use

    You can also copy the core file into your functions file, hack it and rename it. There are several places it needs renaming, and if you would like to post your working solution, I’ll happily make a functions file version, as long as I can use it publicly

    #156383
    Jake Hall
    Participant

    Hi guys,

    the way bbPress outputs the login page bugs me, a lot. What I am trying to do is add a login box to my layout, when I did – I found it added a list and a horrible fieldset around the whole thing. This doesn’t work with my design at all.

    So, on with my quest to change this, I found there is no template readily available to just change. Really? So, it seems all I can do is hack away at the core code, which will all be reverted once a new version comes around.

    Does anyone have any suggestions for this?

    pazzaglia
    Participant

    Thanks, @Robkk I didn’t know how to use that – I didn’t realize it was as easy as adding it to my functions file.

    Thanks for the addition @undergroundnetwork!

    Since I posted I’ve been using this outdated-but-it-works plug-in.
    https://wordpress.org/plugins/search-bbpress/

    Although that plug-in, works, it also displays shows links to slides that I have on the homepage in the results – not a big deal as I don’t have too many slides but I’d rather that not happen.

    In an effort to reduce plug-ins I’m going to give this code a shot.

    Ciao,

    L

    undergroundnetwork
    Participant

    I’ve added to the code as the above code does not search for Forum Titles, this code includes titles in the search as well:

    
    /**
     * Include bbPress 'topic' custom post type in WordPress' search results */
     
    function ntwb_bbp_topic_cpt_search( $topic_search ) {
    	$topic_search['exclude_from_search'] = false;
    	return $topic_search;
    }
    add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' );
    
    /**
     * Include bbPress 'forum' custom post type in WordPress' search results */
    
    function ntwb_bbp_forum_cpt_search( $forum_search ) {
    	$forum_search['exclude_from_search'] = false;
    	return $forum_search;
    }
    add_filter( 'bbp_register_forum_post_type', 'ntwb_bbp_forum_cpt_search' );
    
    /**
     * Include bbPress 'reply' custom post type in WordPress' search results  */
    
    function ntwb_bbp_reply_cpt_search( $reply_search ) {
    	$reply_search['exclude_from_search'] = false;
    	return $reply_search;
    }
    add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );
    
    #156327
    Robin W
    Moderator

    ok, the post count is being out in by something called the bbps ranking system

    the line in the browser comes out as

    <div class=”bbps-post-count”>Post count: 0</div>

    The only reference I can find to this is in this topic

    (CSS Review Needed) Switching poster picture and link to UserPro

    where the plugin author talks about adding different bbpress templates, which add this line – in the example in the link above it shows as

    <div class="bbps-post-count"><?php printf( __( 'Post count: %s', 'Avada' ), bbp_get_user_reply_count_raw(bbp_get_reply_author_id()) ); ?></div>
    
    

    which of course references the avada theme !!!

    If Avada hasn’t asked you to change bbpress files, then I suspect that they might be using the same hook I use to make this appear – suggest you refer Avada back to this post, and ask then if they have a hook to

    do_action (‘bbp_theme_after_reply_author_details’) or can explain why that line appears

    #156321
    j0n4h
    Participant

    Is it not a default feature? When I installed bbpress, it was already a feature from the start. I’ve contacted my Theme dev and they said:

    Hey Jonah,

    I’m not aware of Avada touching the post count code at all. I can see you have a thread open over at the bbPress forum:

    Post Count Incorrect, Repair Tools Don't Fix the Problem.

    I think it would be best to see what they have to say. Hopefully we can use the information they provide to find where the issue is coming from.

    Thanks!

    Ryan

    #156316
    arpitg
    Participant

    i’ve changed previous code

    #156315
    Robin W
    Moderator

    ok, can’t immediately see what it is unhappy with

    need to work out if it is position or what I added

    try

    moving it to where it was
    putting the previous code into the new position

    that should tell us which

    #156312
    arpitg
    Participant

    hello Robin,

    When I copied this code above </form> tag
    <p class=”bbp-user-topic-count”><?php printf( __( ‘Topics Started: %s’, ‘bbpress’ ), bbp_get_user_topic_count_raw($user_id) ); ?></p>
    <p class=”bbp-user-reply-count”><?php printf( __( ‘Replies Created: %s’, ‘bbpress’ ), bbp_get_user_reply_count_raw($user_id) ); ?></p>

    then find a syntax error
    Parse error: syntax error, unexpected ‘Started’ (T_STRING) in /home/cahiveco/public_html/wp-content/plugins/userpro/templates/view.php on line 110

    #156309
    Robin W
    Moderator
    #156308
    Robin W
    Moderator

    ok, I’d do two things

    1. move the code to above </form> line
    2. Try it with the following to force bbpress to take the id

    <p class=”bbp-user-topic-count”><?php printf( __( ‘Topics Started: %s’, ‘bbpress’ ), bbp_get_user_topic_count_raw($user_id) ); ?></p>
     <p class=”bbp-user-reply-count”><?php printf( __( ‘Replies Created: %s’, ‘bbpress’ ), bbp_get_user_reply_count_raw($user_id) ); ?></p>

    `

    #156306
    siddardha
    Participant

    hey robin, here is the entire code:

    <div class=”userpro userpro-<?php echo $i; ?> userpro-id-<?php echo $user_id; ?> userpro-<?php echo $layout; ?>” <?php userpro_args_to_data( $args ); ?>>

    <?php _e(‘Close’,’userpro’); ?>

    <div class=”userpro-centered <?php if (isset($header_only)) { echo ‘userpro-centered-header-only’; } ?>”>

    <?php if ( userpro_get_option(‘lightbox’) && userpro_get_option(‘profile_lightbox’) ) { ?>
    <div class=”userpro-profile-img” data-key=”profilepicture”>profile_photo_url($user_id); ?>” class=”userpro-tip-fade lightview” data-lightview-caption=”<?php echo $userpro->profile_photo_title( $user_id ); ?>” title=”<?php _e(‘View member photo’,’userpro’); ?>”><?php echo get_avatar( $user_id, $profile_thumb_size ); ?></div>
    <?php } else { ?>
    <div class=”userpro-profile-img” data-key=”profilepicture”>permalink($user_id); ?>” title=”<?php _e(‘View Profile’,’userpro’); ?>”><?php echo get_avatar( $user_id, $profile_thumb_size ); ?></div>
    <?php } ?>
    <div class=”userpro-profile-img-after”>
    <div class=”userpro-profile-name”>
    permalink($user_id); ?>”><?php echo userpro_profile_data(‘display_name’, $user_id); ?><?php echo userpro_show_badges( $user_id ); ?>
    </div>
    <?php do_action(‘userpro_after_profile_img’ , $user_id); ?>
    <?php if ( userpro_can_edit_user( $user_id ) ) { ?>
    <div class=”userpro-profile-img-btn”>
    <?php if (isset($header_only)){ ?>
    permalink($user_id, ‘edit’); ?>” class=”userpro-button secondary”><?php _e(‘Edit Profile’,’userpro’) ?>
    <?php } else { ?>
    id_to_member($user_id); ?>” data-template=”edit” class=”userpro-button secondary”><?php _e(‘Edit Profile’,’userpro’); ?>
    <?php } ?>
    skin_url(); ?>loading.gif” alt=”” class=”userpro-loading” />
    </div>
    <?php } ?>
    </div>

    <div class=”userpro-profile-icons top”>
    <?php if (isset($args[‘permalink’])) {
    userpro_logout_link( $user_id, $args[‘permalink’], $args[‘logout_redirect’] );
    } else {
    userpro_logout_link( $user_id );
    } ?>
    </div>

    <?php echo $userpro->show_social_bar( $args, $user_id, ‘userpro-centered-icons’ ); ?>

    <div class=”userpro-clear”></div>

    </div>

    <?php if (!isset($header_only)) { ?>

    <?php
    // action hook after user header
    if (!isset($args[‘disable_head_hooks’])){
    if (!isset($user_id)) $user_id = 0;
    $hook_args = array_merge($args, array(‘user_id’ => $user_id, ‘unique_id’ => $i));
    do_action(‘userpro_after_profile_head’, $hook_args);
    }
    ?>

    <div class=”userpro-body”>

    <?php do_action(‘userpro_pre_form_message’); ?>

    <form action=”” method=”post” data-action=”<?php echo $template; ?>”>

    <input type=”hidden” name=”user_id-<?php echo $i; ?>” id=”user_id-<?php echo $i; ?>” value=”<?php echo $user_id; ?>” />

    <?php // Hook into fields $args, $user_id
    if (!isset($user_id)) $user_id = 0;
    $hook_args = array_merge($args, array(‘user_id’ => $user_id, ‘unique_id’ => $i));
    do_action(‘userpro_before_fields’, $hook_args);
    ?>

    <?php foreach( userpro_fields_group_by_template( $template, $args[“{$template}_group”] ) as $key => $array ) { ?>

    <?php if ($array) echo userpro_show_field( $key, $array, $i, $args, $user_id ) ?>

    <?php } ?>

    <?php // Hook into fields $args, $user_id
    if (!isset($user_id)) $user_id = 0;
    $hook_args = array_merge($args, array(‘user_id’ => $user_id, ‘unique_id’ => $i));
    do_action(‘userpro_after_fields’, $hook_args);
    ?>

    <?php // Hook into fields $args, $user_id
    if (!isset($user_id)) $user_id = 0;
    $hook_args = array_merge($args, array(‘user_id’ => $user_id, ‘unique_id’ => $i));
    do_action(‘userpro_before_form_submit’, $hook_args);
    ?>

    <?php if ( userpro_can_delete_user($user_id) || $userpro->request_verification($user_id) || isset( $args[“{$template}_button_primary”] ) || isset( $args[“{$template}_button_secondary”] ) ) { ?>
    <div class=”userpro-field userpro-submit userpro-column”>

    <?php if ( $userpro->request_verification($user_id) ) { ?>
    <input type=”button” value=”<?php _e(‘Request Verification’,’userpro’); ?>” class=”popup-request_verify userpro-button secondary” data-up_username=”<?php echo $userpro->id_to_member($user_id); ?>” />
    <?php } ?>

    <?php if ( userpro_can_delete_user($user_id) ) { ?>
    <input type=”button” value=”<?php _e(‘Delete Profile’,’userpro’); ?>” class=”userpro-button red” data-template=”delete” data-up_username=”<?php echo $userpro->id_to_member($user_id); ?>” />
    <?php } ?>

    <?php if (isset($args[“{$template}_button_primary”]) ) { ?>
    <input type=”submit” value=”<?php echo $args[“{$template}_button_primary”]; ?>” class=”userpro-button” />
    <?php } ?>

    <?php if (isset( $args[“{$template}_button_secondary”] )) { ?>
    <input type=”button” value=”<?php echo $args[“{$template}_button_secondary”]; ?>” class=”userpro-button secondary” data-template=”<?php echo $args[“{$template}_button_action”]; ?>” />
    <?php } ?>

    skin_url(); ?>loading.gif” alt=”” class=”userpro-loading” />
    <div class=”userpro-clear”></div>

    </div>
    <?php } ?>

    </form>

    </div>

    <?php } ?>

    </div>
    <p class=”bbp-user-topic-count”><?php printf( __( ‘Topics Started: %s’, ‘bbpress’ ), bbp_get_user_topic_count_raw() ); ?></p>
    <p class=”bbp-user-reply-count”><?php printf( __( ‘Replies Created: %s’, ‘bbpress’ ), bbp_get_user_reply_count_raw() ); ?></p>

    #156304

    In reply to: How to start?

    Toni
    Participant

    Because of the intructions I got from the forum – I knew what to look for and found this:

    Step by step guide to setting up a bbPress forum – Part 1


    So I have now The Shortcode. I don’t want to even read the “other” method in detail.
    My opinion: I don’t understand why this set-up must be so laborious.

    #156303
    Toni
    Participant

    Somehow the menu is in order this time. And…

    I found what you were explaining to me, and the shortcode (what I was searching for):

    Step by step guide to setting up a bbPress forum – Part 1

    Thanks again, I knew exactly what to look for this time.

    #156300
    2cats
    Participant

    I am using WP 4.0.1 and bbPress 2.5.4; forums are for members only so I can’t send you a link. I have topics and replies set to show 20; this limitation is also applying to my search results, even if there are more than 20 results for a search term, when I search I am told I’m viewing 20 of 20 found, with no option to see anything more. Is there a way around this? Have I missed a setting, or is there a code snippet I can slip in somewhere? Ideally I’d get 20 results per page, with pagination and the total number of results found. Any help would be greatly appreciated!

    #156295
    Toni
    Participant

    Wait – what is the shortcode? I know how to use them – but I don’t know them.

    #156294

    In reply to: How to start?

    Toni
    Participant

    Also – I had to get instruction from the forum about the purpose and what to do with the /forums/ page that is blank. I still have not found the shortcode.

    #156291

    In reply to: How to start?

    Toni
    Participant

    https://codex.bbpress.org/getting-started-with-bbpress/

    Odd that it takes a couple of links to get there.

    #156286
    Robin W
    Moderator

    can you post the view.php template with your added code here please

    #156280
    Robin W
    Moderator

    ok, the function needs the existence of a variable called $user_id (being the wordpress usreid of the profile user.

    How/where are you adding this code?

    #156274
    Robin W
    Moderator

    That is what the original code does in profile – what happens when you click the links?

Viewing 25 results - 9,826 through 9,850 (of 32,511 total)
Skip to toolbar