Forum Replies Created
-
Got it ! Thanks to a hint from @rogercoathup
Do this:
wp_insert_post with status set to ‘draft’
Then handle file uploads and set the thumb
Then wp_update_post and set the status to ‘publish’
@rogercoathup @modemlooper
thanksThe hardcoded ID is from a prior post – I just wanted to make sure get_the_post_thumbnail was working in the function.
Here is the post dump from the activity-content filter:
`
object(stdClass)#545 (25) { [“ID”]=> int(1298) [“post_author”]=> string(1) “1”
[“post_date”]=> string(19) “2012-09-06 05:48:45”
[“post_date_gmt”]=> string(19) “2012-09-06 12:48:45”
[“post_content”]=> string(4) “test”
[“post_title”]=> string(9) “fghfghfgh”
[“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish”
[“comment_status”]=> string(4) “open” [“ping_status”]=> string(4) “open”
[“post_password”]=> string(0) “” [“post_name”]=> string(9) “fghfghfgh”
[“to_ping”]=> string(0) “” [“pinged”]=> string(0) “”
[“post_modified”]=> string(19) “2012-09-06 05:48:45”
[“post_modified_gmt”]=> string(19) “2012-09-06 12:48:45” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(0) “” [“menu_order”]=> int(0)
[“post_type”]=> string(10) “memberpost” [“post_mime_type”]=> string(0) “”
[“comment_count”]=> string(1) “0” [“ancestors”]=> array(0) { } [“filter”]=> string(3) “raw” }
`I have definitely set a thumbnail for each post – they show up in the edit screen.
So maybe the thumbnail hasn’t been set when I try to filter the activity content ?I use this in functions.php to handle the featured image upload
`
function insert_attachment($file_handler,$post_id,$setthumb=’false’) {if ($_FILES[$file_handler] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);
require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’);
require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’);$attach_id = media_handle_upload( $file_handler, $post_id );
if ($setthumb) update_post_meta($post_id,’_thumbnail_id’,$attach_id);
return $attach_id;
}
`And call it like so:
`
$pid = wp_insert_post($new_memberpost);if ($_FILES) {
foreach ($_FILES as $file => $array) {
$newupload = insert_attachment($file,$pid,true);
}
}
`I’m not sure how to do that via gravity forms.
I use this approach
https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/display-custom-post-types-in-activity-feed/If I include $postid in the $activity_content, it appears in the activity item and is correct.
`
$activity_content = ‘post_id: ‘ . $postid . ‘ + ‘ . bp_create_excerpt( $post->post_content, 25 );
`So why isn’t get_the_post_thumbnail returning the image ?
Maybe the thumb doesn’t exist at that point ?
I’m trying to do this in a plugin file.
‘thumbnail’ is part of my supports array for register_post_type.
And I use get_the_post_thumbnail in the edit screen (template file) for this cpt and it works fine.In reply to: How to retrieve usermeta data on members page ?In function getnewfield() you need to give values to $user_id and $newfield.
Otherwise, they are empty.But for this, I wouldn’t use the do_action.
It’s a template file, so why not put something like this snippet in the while loop$user_id = bp_get_member_user_id(); $data = get_user_meta($user_id, 'newfield'); if ( $data ) echo "<span>New Field Label: $data </span>";Not sure if this works with BP 1.6.
And you’d need to extend it to do what you want.Which editor do you use?
I use notepad++ in which you can over-ride the php highlighting with a user-defined one.
edit: sorry, I misread the op entirely.
I’d like to see an example using an ‘unique ID field buited in BP’s xprofile routine’ that does a client-side check for length and characters.
It would be very useful.
afaik – this is an html issue.
textbox ignores maxlength – it only works on type=input.You can use javascript to limit the length of text entered into a textbox.
But if you’re only allowing 4 number and 2 letters – you should use a input field anyways.
And you’ll probably want to use javascript to check for the allowed char types and number of character types.In reply to: Not getting email notifications and can’t find postsThese are all ‘known’ issues.
And the ‘fixes’ have been pending for awhile.Short of bookmarking your posts, the google search is the only feasible method.
And true, it doesn’t do anything like justice to what BP is capable of.
But if I had to choose between continued release developments of BP and BBPress vs. having this site fully operational, I’d choose the former.
In reply to: BP Core Functions Fatal Error Events ManagerDid you contact the plugin creator?
http://wp-events-plugin.com/In reply to: Displaying content to specific groups.Please put your code between back-ticks `
Try this:`
global $bp; // you might not need the global
if ( bp_is_groups_component() && ‘sports-fitness’ == bp_current_item() )
jnewsticker_display( 0 );
`Within the context of a wp post
$user_id would be get_the_author_id() ?`
$authorBio = xprofile_get_field_data( ‘Bio’, $user_id );echo ‘Author’s bio: ‘. $authorBio;
`You’ll want to start here:
https://codex.buddypress.org/developer-docs/group-extension-api/It’s quite powerful and I’ve used it to do the kind of expansion you describe.
In reply to: [Resolved] Group Extension API – delete buttonFixed – the add_action priority needed to be 1
In reply to: Add subnav item to selected tab in GroupsThis adds the required tab –
add_action( 'groups_admin_tabs', 'add_admin_test_tab', 90, 2); function add_admin_test_tab( $current_tab, $gslug ) { ?> <li class="current"><a href="/admin/test"> <?php }edit – it works, but it’s a very bad idea not to use the API
In reply to: Stop post in social networkChange your admin user name.
or
Create another user, give them admin privileges, and a name other than ‘Admin’.In reply to: Member/User Specific Items using functions.phpYou’re trying to do this in a file in theme/members… ?
Try this:
`
if ( bp_displayed_user_id() == 28 ) {
?>Content only to display on member/user ID 28’s profile page.<?php
}
`btw
-bp_is_user_profile() does not accept variables, it just checks to see if the viewer is on a profile page and returns a boolean.
– add_action doesn’t work like that – read https://codex.wordpress.org/Function_Reference/add_actionGenerally it is not a good idea to use bp_has_members inside a bp_has_members loop.
It probably won’t work, well maybe in BP 1.6.Anyhow, you could try:
`
$user_id=bp_get_member_user_id();
if ( bp_has_members( ‘type=online&populate_extras=0&include=’.$user_id))
`I basically use the approach below to check ‘online’ within members-loop:
(why? don’t recall, but probably because the above approach didn’t work )`
// put this at the top of members-loop$keep_checking_online = true;
function check_user_online_str($get_active_str){
$needles = array(‘hour’, ‘day’, ‘month’, ‘week’, ‘year’);
foreach ($needles as $needle) {
if (stripos($get_active_str, $needle)!==FALSE) return false;
}
return true;
}//in the while loop, put this
<?php
$get_active_str = bp_get_member_last_active();
if ($keep_checking_online) {
$is_online = check_user_online_str($get_active_str);
if ($is_online) echo “Online Now!”;
else {
echo $get_active_str;
$keep_checking_online = false;
}
}
else echo $get_active_str;
?>`
The $keep_checking_online var is used so that the loop stops checking after it finds somebody not online now. This is possible because for bp_has_members( bp_ajax_querystring( ‘members’ ) ) returned members are ordered by last_active.
But we use an online span of 59 minutes – while BP defaults to using 5 minutes.
So you would need to adjust the function check_user_online_str().
If it passes the $needles check, then parse the string to check for ‘minutes’ and ‘seconds’.
If you find ‘minutes’, then get the number after ‘active’ and decide if you want to return true or false.In reply to: Screen Notifications. A comprehensive thread.>So, how do I grab the necessary params from a regular post comment and pass them to a function that will create an activity post comment?
If I understand you correctly – an activity item should be created when you comment on a post page
At least it does on http://testbp.org/activity/ – try it.
( note: on my 1.6 RC1 install – an activity item is NOT created when you comment on a post page – and I don’t know why at this time )So, if on your installed BP version ( which is ? ) , activity items are created when a member comments on a post page, then you should be able to hook into the creation of that item and generate a notification.
If, on your install, activity items are NOT created when a member comments on a post page – then there is another issue and I’d be interested in the answer.
In reply to: Screen Notifications. A comprehensive thread.You should be able to create a hook via:
`do_action(‘wp_insert_comment’, $id, $comment);`which is located ~Line 1259 in wp-includes/comment.php -> wp_insert_comment()