Here is code to have "Add Friend" button displayed in shortcode output
-
In buddypress-foaf.php on line 185 // Random friends of your friends up to add_action(‘widgets_init’, ‘buddypressfoaf_widget_random’);
replace with
// Random friends of your friends $result = $wpdb->get_results($query . " ORDER BY RAND() LIMIT 14"); $output.="<h5>" . __('People you may know', 'buddypressfoaf') . "</h5>"; if ($result) { foreach ($result as $obj) { // get avatar $i++; $actualUser = new BP_Core_User($obj->ID); $output.= '<div style="float:left; text-align: center; margin-bottom: 10px;"><a href="' . $actualUser->user_url . '">' . $actualUser->avatar . '</a><br/>' . bp_core_get_userlink($obj->ID) . '<br /><p style="font-size: 12px;"> ' . $obj->commonContacts . ' ' . __('mutual friends', 'buddypressfoaf'). '</p><p> ' . bp_get_add_friend_button( $actualUser->id ) .'</p></div>'; } //print "<pre>" . var_dump($usersWithCommonFriends); } else { $output.= "<p>" . __('No friends found. Search for some people, add them as friends and come back to this page!', 'buddypressfoaf') . "</p>"; } $output.='<br style="clear:both">'; $output.='<p><a href="' . get_permalink() . '?' . time() . '">' . __('You want to see more? Reload this page!', 'buddypressfoaf') . '</a></p>'; // now we will show the top ten $result = $wpdb->get_results($query . " ORDER BY commonContacts DESC LIMIT 14"); $output.="<h5>" . __('Most of your friends are mutually connected to these people', 'buddypressfoaf') . "</h5>"; if ($result) { foreach ($result as $obj) { // get avatar $actualUser = new BP_Core_User($obj->ID); $output.= '<div style="float:left; text-align: center; margin-bottom: 10px;"><a href="' . $actualUser->user_url . '">' . $actualUser->avatar . '</a><br/>' . bp_core_get_userlink($obj->ID) . '<br /><p style="font-size: 12px;"> ' . $obj->commonContacts . ' ' . __('mutual friends', 'buddypressfoaf'). '</p><p> ' . bp_get_add_friend_button( $actualUser->id ) .'</p></div>'; } } else { $output.= "<p>" . __('No friends found. Search for some people, add them as friends and come back to this page!', 'buddypressfoaf') . "</p>"; } $output.='<br style="clear:both">'; return $output; }
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Here is code to have "Add Friend" button displayed in shortcode output’ is closed to new replies.