Kolya Korobochkin (@korobochkin)

Forum Replies Created

Viewing 25 replies - 26 through 50 (of 59 total)

  • Kolya Korobochkin
    Participant

    @korobochkin

    One more thing. I found some “bug” in my solution. If you use wp_signup_location in MU Plugins directory you need to pass three arguments to add_filter, because mu-plugins loaded before plugins or themes.

    1. MU Plugins
    2. Plugins
    3. Themes

    In MU Plugins:

    add_filter ('wp_signup_location', 'selena_signup_page', 99);
    // You can set up any number greater than 10 (default value).
    // Otherwise your WordPress will be redirect users to wrong page.

    In Theme or Plugin:

    add_filter ('wp_signup_location', 'selena_signup_page');
    // or
    // add_filter ('wp_signup_location', 'selena_signup_page', 99);

    Kolya Korobochkin
    Participant

    @korobochkin

    I’m sorry for few days of silence. My love in the USA, and I’m in Russia without the visa.


    @jeffacubed
    thank you for “спасибо”. I can publish the code. Also I can give you access to my private repo on Bitbucket.

    wp_signup_location – it’s the filter which returns the sign up page location (url) and WordPress redirect to this addres. So this address not using in wp-signup.php because you already on the signup page. Your example of grep result shows that this filter using in wp-login.php (this page have the signup link).

    My code
    All of this files a part of my mu-plugins for this project.

    Require necessary files — gist.github.com/korobochkin/06780b88118e35c3bfd1

    wp-signup.php — gist.github.com/korobochkin/9e4f9cd6502c4252d902 I use selena_network_signup_main function from this file on page-signup.php template in child theme.

    wp-activate.php — gist.github.com/korobochkin/765d0a5d4e028dc3001a I use selena_network_activation_page function from this file on page-activate.php template.

    And finally gist.github.com/korobochkin/a161718855b7784bfb10 file which sends notifications after you create an account and disable default WordPress notifications (return false at the end of the function). If you return true at the end of this function then user get 2 emails with different activation links:
    site.com/wp-activate.php?key=HASH
    site.com/activate/?key=HASH

    P. S. can’t post this reply with links (bbPress doesn’t allow post replies with links).


    Kolya Korobochkin
    Participant

    @korobochkin

    I’m sorry for few days of silence. My love in the USA, and I’m in Russia without the visa.


    @jeffacubed
    thank you for “спасибо”. I can publish the code. Also I can give you access to my private repo on Bitbucket.

    wp_signup_location – it’s the filter which returns the sign up page location (url) and WordPress redirect to this addres. So this address not using in wp-signup.php because you already on the signup page. Your example of grep result shows that this filter using in wp-login.php (this page have the signup link).

    Require necessary files https://gist.github.com/korobochkin/06780b88118e35c3bfd1

    wp-signup.php — https://gist.github.com/korobochkin/9e4f9cd6502c4252d902 I use selena_network_signup_main function from this file on page-signup.php template in child theme.

    wp-activate.php — https://gist.github.com/korobochkin/765d0a5d4e028dc3001a I use selena_network_activation_page function from this file on page-activate.php template.

    And finally https://gist.github.com/korobochkin/a161718855b7784bfb10 file which sends notifications after you create an account and disable default WordPress notifications (return false at the end of the function). If you return true and the end of this function then user get 2 emails with different activation links:
    site.com/wp-activate.php?key=HASH
    site.com/activate/?key=HASH


    Kolya Korobochkin
    Participant

    @korobochkin

    I don’t have experience with subfolder installs but I think there is no difference between subdomain and subfolder installs for this case. I can publish my code but its looks like default wp-signup.php and wp-activate.php with small changes like few <div>, additional CSS classes and commented few lines of code.

    At first glance this two files looks messy and hardcoded but you can Folding all functions and comments in code editor.


    Kolya Korobochkin
    Participant

    @korobochkin

    You just need some functions or methods from Mandrill API instead of my templates 🙂 wp_mail also can send rich text emails (html emails). So you just need pass your html email template to wp_mail for example.

    Also wp_mail by default sends email via PHP Mailer (not SMTP server). I recommend send emails through SMTP server – for protect from spam folder and SMTP server can add dkim record to emails. I dont know anything about Mandrill – maybe your plugin already change wp_mail for SMTP, maybe not. I use https://wordpress.org/plugins/wp-mail-smtp/ plugin for sending emails via SMTP.


    Kolya Korobochkin
    Participant

    @korobochkin

    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;
    }
    ?>

    Kolya Korobochkin
    Participant

    @korobochkin

    I checkout right now this on my site – all working great. I think this issue on your site only (themes or plugins make something bad).
    And yes – delete this terrible avatar =D


    Kolya Korobochkin
    Participant

    @korobochkin

    Damn spammers! Maybe you can set up editor role to users with high rating or registered long time ago? Actually is a big problem (spam) on my sites too. It would be great if some instruments with ratings will be available (like a additional plugin for buddypress or bbpress) 🙂

    Hope you block all spammers! Good luck 🙂


    Kolya Korobochkin
    Participant

    @korobochkin

    @schrully BTW some hosting providers block connects to external SMTP servers (for example – BlueHost) and your Error Type: SMTP show that your server can’t connect to SMTP server.


    Kolya Korobochkin
    Participant

    @korobochkin

    @schrully do you use external plugin and send emails from remote SMTP server?
    I also have this problem on my multisite. Maybe it occurs because bbPress send emails with BCC (one email for all subscribed users and mail services like gmail delete emails thinking that it’s spam)?
    I remove default functions that send emails and write custom functions to send email notifications with cron and all works correctly right now.
    I don’t digg into this issue with default functions. I think the last version of bbPress have bug because previous release sends emails on my site 🙂


    Kolya Korobochkin
    Participant

    @korobochkin

    I have solution for this issue!

    First of all — in web published a lot of strange and bad solutions for this issue. Add some rules to .htaccess, change wp-signup.php directly, blah blah blah…

    I dig into the source code and found something interesting. WordPress have wp_signup_location filter which set up the signup page URL (location).

    require_once (TEMPLATEPATH . '/wp-signup.php');
    function selena_signup_page () {
    	return home_url () . '/signup/';
    }
    add_filter ('wp_signup_location', 'selena_signup_page');

    After this create page-signup.php template in your theme folder with your custom forms (buttons, inputs, etc). Forms and other stuff can be grabbed from wp-signup.php. So I took wp-signup.php from root WP folder and put them to my theme folder. But it needs to edit. I remove some requires, functions and function calls (checkout the wp-signup.php). Be careful!

    Right now I dont know how this technique works with caching (but I use Memcached and Batcache on my sites and all works great).

    Next problem is – activate account page. Similar solution. Create page-activate.php template with require_once ( TEMPLATEPATH . '/wp-activate.php'); call inside. And copy wp-activate.php to your theme folder and then edit them (remove requires, filters and actions). Don’t delete this:

    if ( is_object( $wp_object_cache ) )
    $wp_object_cache->cache_enabled = false;

    This line for caching (I write about this above). Maybe someone tell us about object caching in WP? 🙂

    Now you need disable activation letters (WP sends its twice after this manipulations :). Use wpmu_signup_user_notification filter and your function needs to send emails and return FALSE (or WP send second activation email).

    And that’s all!

    Working example is my sites:

    1. http://armyofselenagomez.com/signup/
    2. http://selenaselena.ru/signup/

    Activation:

    1. http://armyofselenagomez.com/activate/
    2. http://selenaselena.ru/activate/

    It’s a multisite! And both sites also have:

    1. http://armyofselenagomez.com/wp-signup.php
    2. http://armyofselenagomez.com/wp-activate.php
    1. http://selenaselena.ru/wp-signup.php
    2. http://selenaselena.ru/wp-activate.php

    Kolya Korobochkin
    Participant

    @korobochkin

    @robin-w send it. bbpress.org delete spam replies immediately?


    Kolya Korobochkin
    Participant

    @korobochkin

    @olalaweb send it. BTW – write all texts for web in your notepad.exe or other app on your computer because web sucks and I have so many times then I loss my data written in stupid browser.


    Kolya Korobochkin
    Participant

    @korobochkin

    I posted solution for this issue yesterday but it not appeared here. Maybe it marked as spam? Stupid spam filter system!


    Kolya Korobochkin
    Participant

    @korobochkin

    At https://translate.wordpress.org/projects/bbpress/2.5.x I see 99% translated 🙂 You can translate some missing phrases. After that at the bottom of the page choose all current and Machine Object Message Catalog (.mo). Click the Export link. You download the file with translations.
    After that rename downloaded file to bbpress-pt_BR.mo and put it in /wp-content/plugins/bbpress/languages/ and you done.


    Kolya Korobochkin
    Participant

    @korobochkin

    Disable user registration in wordpress.


    Kolya Korobochkin
    Participant

    @korobochkin

    @pooledge just update my super-duper plugin 🙂 now it works fine with all permalink setups. Checkout and update — https://github.com/korobochkin/bbPress-permalinks-with-id

    Known issue
    If permalink looks like site.com?p=123 (not pretty permalink), the topic and reply edit links looks like:

    site.com/?post_type=topic&p=814&topic=TOPIC_SLUG&edit=1
    // TOPIC_SLUG — I dont known right now how to delete it but works fine with this parameter.
    In reply to: Size font bbpress

    Kolya Korobochkin
    Participant

    @korobochkin

    We dont have magical ball. Post link to your site


    Kolya Korobochkin
    Participant

    @korobochkin

    This happens when you change bbPress settings. For example forum slug or topic slug. Right now this can be fixed by flushing rewrite rules manually. My plugin don’t add any rules and hooks on this event. I keep digging into bbPress.


    Kolya Korobochkin
    Participant

    @korobochkin

    I think that add_action (‘init’, ‘bbp_permalinks_init’, 0); is bad. I attach my function with add rewrite rules on bbp_init hook.

    Need to check when you call bbp_init hook.


    Kolya Korobochkin
    Participant

    @korobochkin

    Finally! I find the solution for this issue. flush_rewrite_rules () doesn’t work if you don’t add rules before call it. So we need add our rules on plugin activation and only after this call flush_rewrite_rules (). I call this function and pass false arg because we need soft flush, without .htaccess rewriting.

    Github repo already updated.


    @pooledge
    your forum http://pupyshevo.hol.es/forums/forum/9/ work perfectly with digit in links right now.


    Kolya Korobochkin
    Participant

    @korobochkin

    I check out your site and this f* code just not work. I see that rewrite rules from my plugin not added via add_action ('bbp_init', 'bbp_permalinks_rewrites_init', 29); hook. It’s means that:

    • Hook deleted by other plugin (hm).
    • bbp_init doesn’t exists.
    • My head is broken.

    Maybe someone get us some tips that to check or that to do.


    Kolya Korobochkin
    Participant

    @korobochkin

    @pooledge Can you add me as administrator on this demo site? My email me@korobochkin.com.


    Kolya Korobochkin
    Participant

    @korobochkin

    I found the bug in plugin with some validates. Never liked if ($var) constructions. if ($var !== false && $var !== '') better to understand 🙂

    Just replace content of plugin.php in plugin folder:
    https://github.com/korobochkin/bbPress-permalinks-with-id/blob/master/plugin/plugin.php

    Tested on brand new WordPress install only with bbPress and my plugin with default theme – works as… haha.


    Kolya Korobochkin
    Participant

    @korobochkin

    Oh. So without my plugin your forum work? And you use latest version from Git or not?

Viewing 25 replies - 26 through 50 (of 59 total)