Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Trying to call Simplepress profile and avatar into a CBox chat box
Avatar
Nate
Member
sp_UserOfflineSmall Offline
Apr 10, 2013 - 5:04 pm

I use a chat box on my website called CBox (www.cbox.ws) and it allows Wordpress user integration and also avatar and profile integration. I don't know if this is possible but I would like to call the profile and avatar from Simplepress into the chat box.

Here's the code they gave me http://pastebin.com/K0Pc8nYZ 
There's 2 instances of each: $avatar_url and $profile_url and in these places I'm supposed to "Change $avatar_url and $profile_url to the correct variables for the context." Any idea what simplepress code I should put in these places or is this not going to work?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 10, 2013 - 6:18 pm

assuming you wanted to do this for logged in users only, take a look at this:

http://codex.simple-press.com/.....seravatar/

its how you get the current users avatar... since it will be on non forum pages, I would call it with:

global $current_user; $avatar = sp_UserAvatar('get=1&context=user', $current_user->ID)

then replace $avatar_url with $avatar->url in their code...

for the $profile_url, simply use http://yoursite.com/forum/profile

of course, replace http://yoursite.com/forum with the actual url of your forum main page...

Avatar
Nate
Member
sp_UserOfflineSmall Offline
Apr 11, 2013 - 11:59 am

Thanks for the reply. Neither the avatar or profile works. This is what the CBox admin said:

Change this block: <?php global $user_ID, $user_identity ?>

to: <?php global $user_ID, $user_identity; $profile_url = "http://www.rockitpro.com/sf-fo.....m/profile/" ?>

And then replace both instances of http://www.rockitpro.com/sf-fo.....m/profile/ later in your code with $profile_url

Also, as it stands the profile URL will be the same for every user. You probably want to append some variable to the end of the URL to specify which profile to link. I'm not sure how it works for your setup, but it may be something like:

<?php global $user_ID, $user_identity; $profile_url = "http://www.rockitpro.com/sf-fo.....ile/?user=".$user_ID; ?>

Is there a simplepress variable I need to use along with the profile link? I logged into several names to test and when I click on a name in the chatbox, it takes me to MY profile edit page, not the page to view the user's profile I clicked.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 11, 2013 - 12:12 pm

this all gets back to what I asked originally...  is this for the current logged in user??? 

a profile url IS THE SAME for all logged in users...  when you are logged in, under whatever account, the logged in user profile is http://yoursite.com/forum/profile

but if you dont want the current user and want a specific user, you would do something like:

http://yoursite.com/forum/prof.....user-login

just replace the user-login with the user login for the desired user...  keep in mind, if you dont have access to view that profile, you wont be able to...  permission is based on your settings...  by default it would be allowed...

but lets step back a minute...   you have a really old url structure there... just want to make sure you are running sp version 5.x (since you posted in that forum)...  version 4.x and 5.x are quite different here...  and it almost seems as if you are trying to reference 4.x or the chat folks remember working with 4.x... but since you posted in the 5.x forum, I am giving you 5.x answer...

can you provide more info on the avatar?

Avatar
Nate
Member
sp_UserOfflineSmall Offline
Apr 11, 2013 - 12:52 pm

I recently updated from 4.0 to 5.2.6 a couple of weeks ago so my url structure is still sf-forum. Let me try to word this better, I basically need the call/code to view other people's profile.

CBox is not a plugin but has a Wordpress User Integration option on their site that I enabled, it checks to see if a user of your Wordpress site is logged in and then allows that user to post a message in the chat box without having to log into the chat box separately. So when a user logs into my site they are also logged into the chat box.

If a logged in user says something in the chat box, I want their username to link to their SimplePress profile so that other members can view the profiles. I just need a code that checks the user that's logged in and then links their username to their specific profile. It's like when you click a username in the forum, the popup profile pops up and there's a link at the bottom of the popup to "View Full Profile For UsernameHere", I need that in the chatbox...not the popup (unless it's possible without adding more scripts to my non-forum page) but the direct link to the user's profile.

As for the avatar, I'm going to speak to the CBox admin and see what he says, he forgot to tell me more about that issue.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 11, 2013 - 1:00 pm

so yeah, then use the last one I gave you:

http://yoursite.com/sf-forum/p.....user-login...

if you need some code, try:

global $current_user;
sp_forum_api_support();
$profile_url = sp_url().urlencode($current_user->data->user_login);

Avatar
Nate
Member
sp_UserOfflineSmall Offline
Apr 11, 2013 - 2:00 pm

Using this code http://pastebin.com/tbYbYrgL and it doesn't work, it still links the chatbox poster's username to http://www.rockitpro.com/sf-fo.....m/profile/ which obviously takes me to my own edit profile page, I'm not that knowledgeable in coding really so I'm probably doing something wrong lol. I feel like I need something like:

<?php global $user_ID, $user_identity; $profile_url = "http://www.rockitpro.com/sf-forum/profile/<?php echo get_the_author(); ?>" ?>

Not that but in that style so it grabs the user that posted the message and displays that user's specific profile link.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 11, 2013 - 2:05 pm

the code in your pastebin is trashing (overwriting) the code I gave you....

$profile_url = "http://www.rockitpro.com/sf-forum/profile/user-login" ?

overwrites the correct $profile_url from above that I gave you...  remove it...

and I dont see the code I gave your $avatar_url either...

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 11, 2013 - 2:11 pm

to be clear, use this at top - before the begin cbox stuff...

    <?php 
    global $current_user;
    sp_forum_api_support();
    $profile_url = sp_url().urlencode($current_user->data->user_login);
    $avatar = sp_UserAvatar('get=1&context=user', $current_user->ID);
    $avatar_url = $avatar->url;
    global $user_ID, $user_identity; 
    ?>
Avatar
Nate
Member
sp_UserOfflineSmall Offline
Apr 11, 2013 - 2:38 pm

So this? http://pastebin.com/Ams6ZhqH
I put that code in but it still links the username to http://www.rockitpro.com/sf-fo.....m/profile/ and not for example http://www.rockitpro.com/sf-fo.....e/Sho-Down and doesn't show avatars ( testing on the sidebar on this page http://www.rockitpro.com/testimonies/ )

I'm chalking this up to a problem with the CBox, I'll run this new code (if I did it correctly) by the CBox admin and see what he says on why it doesn't work. Thanks for the help.

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626