Forum Replies Created
-
@djpaul
https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/how-to-paginate-with-bp_user_query/I figure he knows as good as anyone.
Colbert Bump
Also Im using parameters from the posts 2 posts plugin and meta_key for others which the codex doesn’t seem to allow for bp_has_members()
@djpaul Ok because I just thought I was reading about how it was built to scale and I’m dealing with alot of users and large lists.
@modemlooper Really appreciate the explanation! I got it working with infinite scroll on a user ‘s front page to show their posts which is a nice extension. Thanks alot!
@modemlooper Do you see any flaw in my code givin that I’m using xprofile_screen_display_profile? This method worked perfectly when creating loops under say mysite.com/exampleuser/articles/ but its isn’t paging for the top level. It just takes me to a blank members screen. hmmm
kabump
still lost on this
Ohhh. I didn’t know I was actually creating a component just by adding a new nav. Thx @modemlooper!
@djpaul @boonebgorges Could you give this a quick look. I tried adding theme root and theme root uri but now it doesnt even load the stylesheet. So I have this in total to try and load my “MobileThemeBeta” for mobile browsers.
`add_filter( ‘template’, ‘my_mobile_template’, 99999, 1);
function my_mobile_template($template){
if(wp_is_mobile())
return ‘MobileThemeBeta’;
return $template;
}add_filter( ‘theme_root’, ‘theme_root’, 99999, 1 );
function theme_root( $root_path ) {
if (wp_is_mobile())
return ‘MobileThemeBeta’;
return $root_path;
}add_filter( ‘theme_root_uri’, ‘theme_root_uri’, 99999, 1 );
function theme_root_uri( $root_url ) {
if (wp_is_mobile())
return ‘MobileThemeBeta’;
return $root_url;
}add_filter( ‘stylesheet’, ‘my_mobile_stylesheet’, 999999, 1);
function my_mobile_stylesheet($stylesheet){
if(wp_is_mobile())
return ‘MobileThemeBeta’;
return $stylesheet;
}`@rogercoathup How would you change it to make it work?
Fixed. had to rename a plugin to get back into admin. Then ran the wizard and turned it back on and it works again. Fun times.
CLOSED
@boonebgorges @djpaul Can you toss a dog a bone on this? I’d really like to know how to do it.
@karmatosed I had seen that but didn’t see an answer on how to do what I’m trying to do. I need a live validation to show the user whether or not their entry is a valid url for facebook or twitter.
@djpaul @rogercoathup I was able to do it with the following code which seems to be a nice solution for scaling.
<?php //these are the arguments for the get_users function below $args = array( 'fields' => 'all_with_meta', 'role' => 'author', 'meta_query' => array( array( 'key' => 'score', // the meta field (or key) we want to target ) )); //get_users calls WP_User_Query and returns an array of matching users $users = get_users($args); //custom function for comparing the data we want to sort by function cmp($a, $b){ if ($a->score == $b->score) { return 0; } return ($a->score > $b->score) ? -1 : 1; } //usort sorts our $users array with our function cmp() usort($users, 'cmp'); //leaving an array of $users sorted by the value of meta 'points' foreach ($users as $user) { echo '<li>'; echo get_avatar( $user->ID, 30 ); echo '<span>' . $user->display_name . '</span>'; echo '</li>'; } ?>
Yeah that’s a concern. I have a meta value for each user which is a score for that user so I have a need to show list of top 10 scores and stuff like that.
babump
@hnla yeap sure did. I can’t really tell what is so different that is happening but it works lol!
@hnla Thanks for helping. What do I add to bp_init? I tried that in the functions.php but it didn’t do the trick/
kabump
was just about to answer my own question..thanks paul.
@shanebp What I want to do is limit the characters they are allowed to enter into the actual bio.
@djpaul I don’t get it. If I set posts_per_page to -1 it shows all the posts correctly. So why isn’t it allowing to page when I set it to 8? How would you do this if it were you?
@djpaul The loop shows the correct posts for the corresponding author on their profile. I have loop-index.php and loop-member.php and the templates are the same except the beginning of the loop. So I tested the loop-member.php on the homepage adding a specific author id and it triggers the infinite scroll but loads the same 8 posts each time.
@djpaul Ok I rewrote it like this but it’s still not triggering after the post_per_page limit.
`<?php
global $bp;
$user_id = $bp->displayed_user->id;
$my_query = new WP_Query(‘&posts_per_page=8’ . ‘&cat=-1’ . ‘&author=’. $user_id);
if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post(); ?>`What do you recommend?