I am a beginner in coding but i have just wrote this code ,
The concept of code is :
The code adds a form with a button to each user profile. The button is captioned as Follow/ Unfollow. It updates the user meta named "following" for the user who clicked the button (follows). Then we query the user meta with the "following" value to get the list of all users who have subscribed to the authors & list out all posts of those authors.
<?php
if($_GET['follow']){fun1();}
function fun1()
{
$fauid = get_user_by( 'slug', get_query_var( 'author_name' ) );
$user_id= get_current_user_id();
$key = 'following';
$themeta = get_user_meta($user_id , $key, TRUE);
if($themeta != '') {
$user_id= get_current_user_id;
update_user_meta($user_id, 'following', $fauid); }
else {
$user_id= get_current_user_id;
add_user_meta($user_id , 'following' , $fauid , true );
update_user_meta($user_id, 'following', $fauid);
}
}
?>
<html>
<button id="Button" name="Button" onClick='location.href="?follow=1"'>Follow Me <3 <3</button>
</html>
Is the code right or not?