-
-
Save champsupertramp/191a95ae3212ceb8085d to your computer and use it in GitHub Desktop.
<?php | |
add_action('um_after_new_user_register','um_auto_follow_artists',10,2); | |
function um_auto_follow_artists( $user_id, $args ){ | |
global $ultimatemember, $um_followers; | |
$follow_users = array( | |
'rjtmusic', | |
'james-peacock', | |
'carl-thomson', | |
'jonathan-proud', | |
'stu-dawson', | |
'carly-mckee', | |
); | |
foreach( $follow_users as $username ){ | |
$follow_user = get_user_by( 'login', $username ); | |
$um_followers->api->add( $follow_user->ID, $user_id ); | |
} | |
} | |
?> |
Hi Champ,
This is just what I was looking for.
How would I adjust the code to follow max 100 members ranked in order of how many friends they have?
Thanks
Patrick
where will I paste this code? function.php ?
Please help me
Hi @emmyloaded
You can use this plugin to add the code snippet:
https://wordpress.org/plugins/code-snippets/
Regards,
Hi @emmyloaded
You can use this plugin to add the code snippet:
https://wordpress.org/plugins/code-snippets/Regards,
What will I edit here? the name of the special users I want other users to follow or user ID
Hi @emmyloaded,
IF you want the newly registered user to follow specific users by ID, you can try the following:
add_action('um_user_register','um_auto_follow_members',5,2);
function um_auto_follow_members( $user_id, $args ){
$follow_users_IDs = array(
1,
33,
444,
);
foreach( $follow_users_IDs as $follow_user_id ){
UM()->Followers_API()->api()->add( $follow_user_id, $user_id );
}
}
$user_id
- this is the ID of the newly registered user
$follow_users_IDs
- these are the user IDs who will be followed by the newly registered user.
Regards,
Hi @emmyloaded,
IF you want the newly registered user to follow specific users by ID, you can try the following:
add_action('um_user_register','um_auto_follow_members',5,2); function um_auto_follow_members( $user_id, $args ){ $follow_users_IDs = array( 1, 33, 444, ); foreach( $follow_users_IDs as $follow_user_id ){ UM()->Followers_API()->api()->add( $follow_user_id, $user_id ); } }
$user_id
- this is the ID of the newly registered user
$follow_users_IDs
- these are the user IDs who will be followed by the newly registered user.Regards,
excatly what i'm saying... my special user IDs are 1, 2, 4,
thanks i really appriciate that. i have over 20,000 registerd users now, even the admin has only 50 followers is there anyway to do the old users ?
Have tried it my follower is not increasing
Hello
Hi @emmyloaded,
IF you want the newly registered user to follow specific users by ID, you can try the following:
add_action('um_user_register','um_auto_follow_members',5,2); function um_auto_follow_members( $user_id, $args ){ $follow_users_IDs = array( 1, 33, 444, ); foreach( $follow_users_IDs as $follow_user_id ){ UM()->Followers_API()->api()->add( $follow_user_id, $user_id ); } }
$user_id
- this is the ID of the newly registered user
$follow_users_IDs
- these are the user IDs who will be followed by the newly registered user.Regards,
Please explain this better please.. I don’t understand to use this
Updates for UM 2.0 compatibility