Forum Replies Created
-
back after a week of struggling. anybody got any ideas?
lol, just so you know: this is what i’m working on right now. lol. i’ll let you know IF i can get it working.
with number 1, id assume you’d have to loop all updates and pull out the meta on the track information.
with number 2, where would you send the link? to a webservice?
in summary:
when you post items from a modified post-form.php you’re sending them through some ajax, and functions inside global.js.
what i had to do was edit the values that were passed into the ajax inside global js.
i have 3 fields, artist, track and cover.
j.post( ajaxurl, {
action: ‘post_update’,
‘cookie’: encodeURIComponent(document.cookie),
‘_wpnonce_post_update’: j(“input#_wpnonce_post_update”).val(),
‘content’: content,
‘artist’: artist, <<<
‘track’: track, <<<
‘cover’: cover, <<<
‘object’: object,
‘item_id’: item_id
},
(arrows added for effect)
after that, a function in bp-custom.php can pick them up and use them as metas for the post.
more experimentation leads me to this solution:
items from the form are passed through global.js
i found and modified the posted items to include /match my new fields:
/* Default POST values */
var object = ”;
var item_id = j(“#whats-new-post-in”).val();
var content = j(“textarea#whats-new”).val();
var artist = j(“input#artist”).val();
var track = j(“input#track”).val();
/* Set object for non-profile posts */
if ( item_id > 0 ) {
object = j(“#whats-new-post-object”).val();
}
j.post( ajaxurl, {
action: ‘post_update’,
‘cookie’: encodeURIComponent(document.cookie),
‘_wpnonce_post_update’: j(“input#_wpnonce_post_update”).val(),
‘content’: content,
‘artist’: artist,
‘track’: track,
‘object’: object,
‘item_id’: item_id
},
and it worked just fine. _POSTed items are now available in my bp-custom.
Well, it looks like i spoke too soon.
I cannot get: any $POST’ed information inside here:
function add_trackmeta_to_activity( $content, $user_id, $activity_id ) {
bp_activity_update_meta( $activity_id, ‘trackmd5’, md5($_POST[‘trackstr’]) );
}
$_POST[‘trackstr’] was returning an empty string, md5 hashed.
can anyone here jump in and help? why cant i get posted items inside my bp-custom.php?
oh lordy, i think i sorted it, and for those interested, here is the deal:
– in post-form.php, i have another input field with the ID: ‘trackstr’
– create a plugin in wp-content/plugins: ‘bp-custom.php’
– customise the below function to your custom capture needs:
function add_trackmeta_to_activity( $content, $user_id, $activity_id ) {
bp_activity_update_meta( $activity_id, ‘trackmd5’, md5($_POST[‘trackstr’]) );
}
add_action( ‘bp_activity_posted_update’, ‘add_trackmeta_to_activity’, 10, 3 );
function my_trackmeta() {
$my_trackmeta = bp_activity_get_meta( bp_get_activity_id(), ‘trackmd5’ );
//if (is_user_logged_in()) : {
echo ‘<span class=\’trackmeta-md5\’>(‘ . $my_trackmeta . ‘)</span>’;
//}
//endif;
}
add_action( ‘bp_activity_entry_meta’, ‘my_trackmeta’ );
… additional metadata is captured and stored with your posts.
sorry for not searching and readin up on this before i jumped in and gave it a go chaps and chapettes, but here is how i solved my own problem anyhow.
I think this is what i want:
https://buddypress.org/forums/topic/extending-activity-how-to-store-additional-info
And i’v implimented a simple plugin:
function add_trackmeta_to_activity( $content, $user_id, $activity_id ) {
bp_activity_update_meta( $activity_id, ‘trackmd5’, md5($_POST[‘trackstr’]) );
}
add_action( ‘bp_activity_posted_update’, ‘add_trackmeta_to_activity’, 10, 3 );
And it does not crash, or complain, but where does my data go? and how can i access it in my templates?