1

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?

1
0

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.

1
  • 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 ^_^ ? Jan 10 '15 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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