friends plugin search function in global header

Hello,

I’m putting together a global header that has an add to friends function of the ‘friends plugin’ by Andrew Billitis in my global header.

I want to pull this off by hardcoding the add to friends search function into my global header.

I figured I would echo the site owners name to the search function (over at friends.php?page=find-friends) , which would then dynamicly produce the "(add) %SITEOWNER" or whatever, link and run the function from friends.php?page=find-friends, when clicked. thereby creating an "add this blog owner to your friends!" button.

Anyone give me a hint as to how to call these functions?

  • mirozake
    • New Recruit

    OKay, here is the working code. Only problem is that when placed in a global header, it thinks the current blog is the main blog and pulls the main blogs ID instead of the current blog. I havn’t figured out a work around yet… hopefully i will

    <?php
    $current_site = get_current_site();
    echo '(<a href="wp-admin/friends.php?page=find-friends&action=add&id=' .$current_site->id . '">' . __('Add') . '</a>) ';
    ?>

  • mirozake
    • New Recruit

    !SOLVED!

    I have created an ‘add to friends’ button for a global header. it uses ‘get blog owner’ plugin and my code goes

    <?php
    $user_info = get_blog_owner();
    echo '(<a href="wp-admin/friends.php?page=find-friends&action=add&id=' .$user_info->ID . '">' . __('Add To Friends') . '</a>) ';
    ?>

  • mirozake
    • New Recruit

    Another quick question..

    Im trying to keep from navigating away from the page.. How should work it so that I stay on the current blog when I use my ‘add to friend’ button? currently I am using this code in my global header.. any help?

    <?php
    global $current_blog;
    $blog_id = $current_blog->blog_id;
    echo 'You are viewing blog id '.$blog_id;
    $user_info = get_blog_owner();
    echo('User ID: ' . $user_info->ID . "n");

    $current_site = get_current_site();
    echo 'this site is part of '.$current_site->site_name;
    echo '(<a href="wp-admin/friends.php?page=find-friends&action=add&id=' .$user_info->ID . '">' . __('Add') . '</a>) ';
    ?>

    see it in action here http://johnsmith.alterplanet.com

    *NOTE, I cant edit the earlier post, so this will have to be as good a spot as any. But just to help ease some confusion about get_current_site as there is a serious lack of clarity. I want to just simply mention that, get_current_site always shows id 1 because the WHOLE mu installation is site #1 (unless you are managing multiple mu installs), what you need is to work with get_blog_owner ! Just thought that this little note would help people in a similar spot as i found myself yesterday searching google for ‘wpmu get_current_site id 1 why?’….

  • mirozake
    • New Recruit

    Thanks for the quick reply, Andrew.

    I’ve been looking through some info on javascript forms,

    Perhaps you could give me a hint as to where to start? should I be trying to use a javascript form to submit $user_info->ID to some part of the friends-framework.php?

  • mirozake
    • New Recruit

    im playing with something like this now

    <input type="button" name="button" value="add to friends"
    onclick="javascript:POST("wp-admin/friends.php?page=find-friends&action=add&id=' .$user_info->ID . '", '');">

    what do you think?

  • Andrew
    • Champion of Loops

    I think you’re going to need to do two additional things:

    1) Disable the button after they press it so they won’t repeatedly add the user as a friend.

    2) Check to see (db query) if the user is already a friend and if so disable the button so the user can’t press it to begin with.

    Thanks,

    Andrew

  • mirozake
    • New Recruit

    alright. Could you take a look at my code in my previous post. I gotta get that post to function before I can add those other two pieces. but yah, there important and Ill probably end up trying to use the code you already have set up over at friends-functions.php of the ‘friends’ plugin. Thanks again for all your help

    *perhaps I should just copy/paste the appropriate pieces from friends-function.php into my header?

    *i’m having trouble finding an appropriate tutorial

  • Andrew
    • Champion of Loops

    Hiya,

    I’m afraid I just don’t have time to test your code at the moment. Our focus here is on support for our plugins and this is really a custom feature. You may want to consider hiring a developer. It shouldn’t take anyone more than an hour.

    Thanks,

    Andrew

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.