Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8781763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:23:20+00:00 2026-06-13T20:23:20+00:00

I’m trying to implement twitter like followers function in my website. I have a

  • 0

I’m trying to implement twitter like followers function in my website. I have a function like this in my plugin:

function current_profile_user_id() {
   return "current profile user id";
}
function button( $args = '' ) {
        $defaults = array(
            'leaderid'   => current_profile_user_id(),
            'followerid' => 'logged in user id'
        );
        return "HTML button";
    }

The only way I can pass the current profile user id value, its from the user profile page by using function arguments.

Let’s say the $currentuser->ID returns the current profile page user value but this variable only available in the profile page.

Can anyone tell me how to pass that value to the function current_profile_user_id(), store that value and return the html button?

Please note: Many of my other functions too uses the value returned by current_profile_user_id().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:23:22+00:00Added an answer on June 13, 2026 at 8:23 pm

    You had better save the value in the session. A function may rely on the global scope, but that is not saved between pages.

    You could do something like

    function currentProfile($profile = False)
    {
        if ($profile)
            $_SESSION['curr_profile'] = $profile;
        else
            if (isset($_SESSION['curr_profile']))
                return $_SESSION['curr_profile'];
        return $profile;
    }
    
    function current_profile_user_id()
    {
        return currentProfile()->ID;
    }
    

    and then, as soon as you can, save the profile in session

    currentProfile($currentuser);
    

    …ought to work. This way, you can change the persistence of curr_profile if need be, without having to revisit all of your code.

    on a maybe-related note

    (Not being very clear on what you’re attempting to do and how, I hope this may turn out to be useful)

    So you have a list of users and want to display a ‘follow’ template for each. The list of users is retrieved from some sort of database, so you’ll have something like

    while($user = $st->fetch(PDO::FETCH_ASSOC))
    {
        // Populate the template
    
        // Append template to display code
    }
    

    In that template you will have something like:

    <a href="follow.php?id={$user['id']}">Follow {$user['name']}</a>
    

    or maybe an AJAX call to add that user to the logged user’s follow-list without refreshing the page. Anyway, there will be a server page invoked, and that page will receive a session cookie and the ID the user selected.

    So that page will have to note the new following/unfollowing, and it will have everything it needs to do so:

    1. The ID of the user to be followed, in $_REQUEST['id']
    2. All data of the follower, in $_SESSION.

    It could then execute, for example, a query such as

     INSERT IGNORE INTO followers (follower, followee) VALUES ($id1, $id2);
    

    to persist the information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.