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.



 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);


    <button id="Button" name="Button" onClick='location.href="?follow=1"'>Follow Me <3 <3</button>

Is the code right or not?


1 Answer 1


Best way to find if a code works or not is to actually try it ;) On the face of it, it doesn't look like you are trying to handle storing the user ids in an array or any serialized way at all.

  • Thanks Mr Mark :) I am a Beginner in coding i have written this code after a long time of searching in Google , Can you help me please ^_^ ? Commented Jan 10, 2015 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.