Forum Replies Created

Viewing 10 Topics - 1 through 10 (of 10 total)
Author Posts
July 3, 2013 at 1:42 pm in reply to: Post to Buddypress Actvities 5532
quokka quokka

Hi..

Try to add:

print_r($post);
under:

global $post;

Does that return anything?
Looks no post is passed to the function..

July 2, 2013 at 10:22 pm in reply to: Post to Buddypress Actvities 5508
quokka quokka

Hi..
That’s normal…

The true is for returning a single custom field value..
http://codex.wordpress.org/Function_Reference/get_post_meta

Try changing this:
if( $post-_post_type == 'post' ) {

To:

if( $post->post_type == 'post' ) {

Does that fix it?

Regards,
Bas

quokka quokka

Hi Tareq,

The dashboard code is in a WP page.
Where should I modify the url manually?
In WPUF plugin code? Hope not 😉

Thanks,
Bas

June 11, 2013 at 8:52 pm in reply to: Post to Buddypress Actvities 4807
quokka quokka

Hi Mahi,

Sure no problem..I will include the custom post type code from my functions-custom.php as well together with some screenshots..

Can take a day or two because I’m very busy playing with you cool WPUF plugin ;-D

Take care and keep up the great work at Wedevs.com!
Bas

June 11, 2013 at 8:29 pm in reply to: Post to Buddypress Actvities 4805
quokka quokka

Hi Tareq (and anybody else that maybe interested)…

I managed to get this little plugin of mine working.

When I create a new post (of custom post type ‘photoalbum’) with WP User Frontend Pro this plugin also writes the activity to the Buddypress Activity Stream.

To use this with your own custom post type just search/replace for ‘photoalbum’ and replace with ‘your_custom_post_type_name’

Grab the code and save it as a WordPress plugin and you should be fine..

Thanks Tareq for pointing me in the right direction, and for making those handy action hooks available in WP User Frontend Pro 😀

Take care!
Bas

The plugin code:


<?php
/*
Plugin Name: Photoalbum CPT 2 Buddypress Activity Stream
Plugin URI: http://www.basdebie.com
Description: This plugin hooks into WP User Frontend and posts to the Buddypress Activity Stream on new photoalbum submission
Version: 1.0
Author: Bas Debie
Author URI: http://www.basdebie.com
License: GPL2
*/
 
 
 /**
 * Record an activity item
 * This code is taken from Nicolas Crocfer's BuddyPress Portfolio Plugin
 */
function bd_custom_bp_record_activity( $args = '' ) {
	if ( !function_exists( 'bp_activity_add' ) )
		return false;

	$defaults = array(
		'id' => false,
		'user_id' => '',
		'action' => '',
		'content' => '',
		'primary_link' => '',
		'component' => 'photoalbum',
		'type' => false,
		'item_id' => false,
		'secondary_item_id' => false,
		'recorded_time' => gmdate( "Y-m-d H:i:s" ),
		'hide_sitewide' => false
	);

	$r = wp_parse_args( $args, $defaults );
	extract( $r );
	return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
}

/**
 * After post photoalbum update the Buddypress Activity Stream
 */
function bd_after_photoalbum_insert( $post_id ) {
	
	global $bp;
	if( get_post_type( $post_id ) == "photoalbum" ) {
	bd_custom_bp_record_activity( array(
				'user_id' => $bp->loggedin_user->id,
				'action' => sprintf(__('%s added the Photoalbum \''.get_the_title($post_id).'\' at %s','bd-photoalbum'), "<a href='".$bp->loggedin_user->domain."/'>".$bp->loggedin_user->fullname."</a>", get_permalink( $post_id ) ),
				'primary_link' => get_permalink( $post_id ),
				'type' => 'new_photoalbum',
				'item_id' => $bp->loggedin_user->id,
			));
	}

}
add_action( 'wpuf_add_post_after_insert', 'bd_after_photoalbum_insert' );

?>
June 11, 2013 at 7:24 pm in reply to: Post to Buddypress Actvities 4801
quokka quokka

;-D

You are right, seems like php mail() function not working on that domain hosting account. Tried on another domain / WP install and working fine!

Thanks Tareq,
If I manage to get this working I’ll post it here for other Buddypress users..
Bye…
Bas

June 11, 2013 at 7:10 pm in reply to: Post to Buddypress Actvities 4797
quokka quokka

I activated this simple plugin and when I add or update a post with the WPUF forntend form, nothing seems to happen..

Thanks!

June 11, 2013 at 7:09 pm in reply to: Post to Buddypress Actvities 4796
quokka quokka

Hi Tareq,

Thanks…i’m aready fooling around..
Can you tell me what I’m doing wrong please?
I didn’t play with action hooks before and while it looks pretty simple, I even can’t get this working:

<?php
/*
Plugin Name: Do action after insert or update
Plugin URI: http://www.basdebie.com
Description: Testing the action hooks of WPUF
Version: 1.0
Author: Bas Debie
Author URI: http://www.basdebie.com
License: GPL2
*/

function bd_trigger_wpuf_update_insert( $post_id ) {
    //update_post_meta( $post_id, 'artist', $_POST['song_artist'] );
	$to = "my_email_addres@domain.com";
	$subject = "Test mail from plugin";
	$message = "Hello! This is a test mail from plugin";
	$from = "my_email_addres@domain.com";
	$headers = "From:" . $from;
	mail($to,$subject,$message,$headers);
}
add_action( 'wpuf_add_post_after_insert', 'bd_trigger_wpuf_update_insert' );
add_action( 'wpuf_add_post_after_update', 'bd_trigger_wpuf_update_insert' );

?>

Thanks!
Bas

June 11, 2013 at 5:14 pm in reply to: Post to Buddypress Actvities 4792
quokka quokka

Looking at WPUF documentation and seems to me like the action hooks wpuf_add_post_after_insert ans wpuf_edit_post_after_update could be used to call a function likke the bp_portfolio_record_activity above that writes to the activity stream, or in’t it that easy?

Thanks,
Bas

June 11, 2013 at 9:02 am in reply to: Post to Buddypress Actvities 4788
quokka quokka

Hi Tareq,

Thanks for the great plugin!
I used it to create a front end post form to submit to main blog in Buddypress.
Also I created a custom post type ‘imagegalleries’ where users can post photo’s to with WPUF.
Amazingly easy with WPUF!

One concern..
I would like the activity of posting to my custom post type and blog to be recorded in the BP activity stream..

I have been looking on how other plugins do it.
For example the BP Portfolio plugin logs all activity to the stream..

BuddyPress Portfolio

[php]/**
* Record an activity item
*/
function bp_portfolio_record_activity( $args = ” ) {
global $bp;

if ( !function_exists( ‘bp_activity_add’ ) )
return false;

$defaults = array(
‘id’ => false,
‘user_id’ => $bp->loggedin_user->id,
‘action’ => ”,
‘content’ => ”,
‘primary_link’ => ”,
‘component’ => $bp->portfolio->id,
‘type’ => false,
‘item_id’ => false,
‘secondary_item_id’ => false,
‘recorded_time’ => gmdate( "Y-m-d H:i:s" ),
‘hide_sitewide’ => false
);

$r = wp_parse_args( $args, $defaults );
extract( $r );

return bp_activity_add( array( ‘id’ => $id, ‘user_id’ => $user_id, ‘action’ => $action, ‘content’ => $content, ‘primary_link’ => $primary_link, ‘component’ => $component, ‘type’ => $type, ‘item_id’ => $item_id, ‘secondary_item_id’ => $secondary_item_id, ‘recorded_time’ => $recorded_time, ‘hide_sitewide’ => $hide_sitewide ) );
}
<pre><code>

bp-portfolio-activity.php has a function o update the stream and i gets called on every post creation or update.
</code></pre>
// Records an activity
if($result = $portfolio->save()) {

/* Now record the activity item */
$user_link = bp_core_get_userlink( $bp->loggedin_user->id );

$project = new BP_Portfolio_Item( array( ‘id’ => $result ) );
$project->get();

$title = $project->query->post->post_title;
$user_portfolio_link = ‘<a href="’. bp_core_get_user_domain($bp->loggedin_user->id) . BP_PORTFOLIO_SLUG . ‘">portfolio</a>’;

if($id) {
// Edit an existing item
bp_portfolio_record_activity( array(
‘type’ => ‘edit_project’,
‘action’ => apply_filters( ‘bp_edit_portfolio_activity_action’, sprintf( __( ‘%s edited the <strong>%s</strong> project in his %s’, ‘bp-portfolio’ ), $user_link, $title, $user_portfolio_link ), $user_link, $title, $user_portfolio_link ),
‘item_id’ => $bp->loggedin_user->id,
) );
}
else {
// New item, so new activity
$description = $project->query->post->post_content;
$url = get_post_meta($result, ‘bp_portfolio_url’, true);

$attachment = wp_get_attachment_image_src($project->query->post->post_parent, ‘portfolio-thumb’);
if($attachment != 0)
$thumbnail = apply_filters( ‘bp_portfolio_get_item_thumbnail’, $attachment[0]);
else
$thumbnail = apply_filters( ‘bp_portfolio_get_item_thumbnail’, BP_PORTFOLIO_PLUGIN_URL . ‘/templates/’ . BP_PORTFOLIO_TEMPLATE . ‘/img/default.png’);

$activity_content = sprintf(__( ‘<div class="item-project"><div class="item-project-pictures"><img width="250px" height="170px" src="%s"></div><div class="item-project-content"><div class="item-project-title">%s</div><div class="item-project-url"><a href="%s">%s</a></div><div class="item-project-desc">%s</div></div></div></div>’, ‘bp-portfolio’), $thumbnail, $title, $url, $url, $description);

bp_portfolio_record_activity( array(
‘type’ => ‘new_project’,
‘action’ => apply_filters( ‘bp_new_portfolio_activity_action’, sprintf( __( ‘%s created a new project in his %s’, ‘bp-portfolio’ ), $user_link, $user_portfolio_link ), $user_link, $user_portfolio_link ),
‘content’ => $activity_content,
‘item_id’ => $bp->loggedin_user->id,
) );
}

return true;
}[/php]

Any chance you could build this support into WPUF?
I’m willing to sponsor the development, maybe ggsalas is interested too?

Thanks!
Bas

Viewing 10 Topics - 1 through 10 (of 10 total)