Reply To: Probleme using BP core functions
Here is the code I’m trying to make work. Maybe it’ll help:<?php
/*
Plugin Name: My Plugin
Plugin URI: https://*******.com/
Description: Remove inactive users from friends
Version: 0.1
Authors: mika89
*/
/* Definition des constantes */
define('BP_AI_PLUGIN_NAME', 'myPlugin');
define('BP_AI_PLUGIN_URL', plugins_url('',__FILE__));
define('BP_AI_PLUGIN_URL_JS', plugins_url('js',__FILE__));
define('BP_AI_PLUGIN_URL_CSS', plugins_url('css',__FILE__));
define('BP_AI_PLUGIN_URL_IMG', plugins_url('images',__FILE__));
define('BP_AI_PLUGIN_DIR', WP_PLUGIN_DIR.'/'.BP_AI_PLUGIN_NAME);
define('BP_AI_PLUGIN_VERSION', '0.1');
/* Return the current day of the week */
function getToday(){
$jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
return jddayofweek($jd,1);
}
/* Update users to inactive role */
function updateToInactive(){
if(getToday() == "Monday"){
/* Not done yet*/
}
}
/* remove inactive members from friends */
function removeInactiveFromFriends(){
$args = array('count_total' => true);
$user_query = new WP_User_Query($args);
?>
<pre>
<?php
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
$user_friends = friends_get_friend_count_for_user($user->id);
echo '<p>' . $user->display_name . '</p>';
foreach ( $user_friends->results as $friend ) {
echo '------------<p>' . $friend->display_name . '</p>';
}
}
}
else {
echo 'No users found.';
}
?></pre><?php
}
removeInactiveFromFriends();
?>