Home Forums Plugin Support WP User Frontend Pro Post to Buddypress Actvities

This topic is: not resolved

This topic contains 24 replies, has 5 voices, and was last updated by  Aaron 4 years, 6 months ago.

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #5508

    quokka
    Participant
    Post count: 10

    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

    #5524

    Tareq Hasan
    Keymaster
    Post count: 2831

    You should return true. return get_post_meta($post->ID, 'txt_link', true);

    #5530

    ggsalas
    Participant
    Post count: 108

    @quokka I tried your change but no result.
    @tareq When I set get_post_meta to “true” I have no results.

    In this code the only text appears is “This”:

    add_filter( 'bp_blogs_activity_new_post_content', 'record_post_activity_content',1, 3 );
    function record_post_activity_content($activity_content, $post,$post_permalink ){
    global $post;
    return get_post_meta($post->ID, 'txt_link', true).'This';
    }

    Thanks for your help, I hope can resolve.

    #5532

    quokka
    Participant
    Post count: 10

    Hi..

    Try to add:

    print_r($post);
    under:

    global $post;

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

    #5561

    ggsalas
    Participant
    Post count: 108

    Yes @quokka the problem is that i can't get the post id. I tried with this code and it works:
    return get_post_meta(577, 'txt_link', true).'This1';
    How I can get the post ID? Adding print_r($post); not work.

    #5563

    ggsalas
    Participant
    Post count: 108

    I found that the blog post ID is the “secondary_item_id” parameter in bp_blogs_record_activity()

    But I not find a way to get the post id.

    #5691

    ggsalas
    Participant
    Post count: 108

    Hi @tareq,

    Today I check that this code is working perfectly creating a post with wordpress and not working with WPUF Pro.

    I don't know what info you need to resolve it. I have no problem to test in my site.

    Thanks

    #5694

    ggsalas
    Participant
    Post count: 108

    Apparently the problem is that WPUF not use the “save_post” WordPress action. This is the support answer I recive in WPMUDEV.

    #5885

    ggsalas
    Participant
    Post count: 108

    Hi @quokka I have tested your plugin and do the same error:

    plugin actiity add

    <?php
    /*
    Plugin Name: WPUF POSTS TO 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 modif.
    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' => 'post',
    		'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 update the Buddypress Activity Stream
     */
    function bd_after_post_insert( $post_id ) {
    	
    	global $bp;
    	$activity_content = get_post_meta($post->ID, 'txt_link', true).'this yes ahora';
    	// if( get_post_type( $post_id ) == "photoalbum" ) {
    	bd_custom_bp_record_activity( array(
    				'user_id' => $bp->loggedin_user->id,
    				'action' => sprintf(__('%s creó una nueva publicación \''.get_the_title($post_id).'\' at %s'), "<a href='".$bp->loggedin_user->domain."/'>".$bp->loggedin_user->fullname."</a>", get_permalink( $post_id ) ),
    				'primary_link' => get_permalink( $post_id ),
    				'type' => 'new_post',
    				'item_id' => $bp->loggedin_user->id,
    			));
    	// }
    
    }
    add_action( 'wpuf_add_post_after_insert', 'bd_after_post_insert' );
    
    ?>
    #32576

    Aaron
    Member
    Post count: 39

    Can i get this to work using WPUF Registration Form? So when someone registers to my site it will post to the Buddypress Activity?

    Thanks

Viewing 10 posts - 16 through 25 (of 25 total)

The topic ‘Post to Buddypress Actvities’ is closed to new replies.