Is this code true or not ?!
-
I am a beginner in coding but i have just wrote this code and i got an error ??
this code must be placed in author.php file , so it creates a follow button in author’s page
and when i click on it , it should save the author-id in a logged-in user meta called “following” ..
<?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>but i think this meta have to be an “array variable” in order not to replace the previous author id
with the new one .
anyone can help me please ?
- The topic ‘Is this code true or not ?!’ is closed to new replies.