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
get user id
Avatar
Carlos
Spain
Member
Free Members
sp_UserOfflineSmall Offline
Mar 1, 2014 - 1:28 am

Hi! i want to show a extra html info on the profile... the main code on any wp page is:

<?php echo userpro_show_badges( $user_id, $inline=false ); ?>

 

I trying to implement it on the  topicview.php but I´m having problems getting the user id of the post...

 

this is the code i´m using

echo '<div class="spPostUserLocation spCenter">';
echo userpro_show_badges( $user_id, $inline=false );
echo '</div>';

but no luck getting the user id....

 

I have been reading and some users are adding something like:

 

$user_id = get_the_author_meta(‘ID’);

Can anyone bring me help with this? 

 

 

 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 1, 2014 - 4:50 am

If you are referring to putting your code within the forum post 'loop' then the ID of the current author of the individual post can be obtained from:

$spThisPostUser->ID

Functions like get_the_author_meta() are strictly WP and refer to WP 'posts'.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Carlos
Spain
Member
Free Members
sp_UserOfflineSmall Offline
Mar 1, 2014 - 5:38 am

and that code will retrieve de wp user id?

 

how must i integrate it?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 1, 2014 - 5:42 am

If it is used in the within 'post loop' on the spTopicView.php theme template then yes - it returns the ID of the current post author being displayed.

Not sure what you mean by 'integrate it'. It returns the users ID. What you have in your function above as $user_id

andy-signature.png
YELLOW
SWORDFISH
Avatar
Carlos
Spain
Member
Free Members
sp_UserOfflineSmall Offline
Mar 1, 2014 - 6:51 am

thanks it works :)

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 1, 2014 - 11:21 am

cool... thanks for the update..

Avatar
Trevor Lyman
Member
Free Members
sp_UserOfflineSmall Offline
May 16, 2014 - 10:30 am

I'm looking to do this, but I want to key off of the user that initiated the post only.  So if user 15 starts a post I want certain things to happen based on that and only that. 

Do I get a different type of userID for this?  Is there a "post starter ID" or anything like that that I can key off of?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 16, 2014 - 1:27 pm

You haven't mentioned where you want to do this... It may vary...

Take a look at forum - toolbox - data inspector where you can display available global data based on page view...

User ID is available just need more specifics....

Avatar
Trevor Lyman
Member
Free Members
sp_UserOfflineSmall Offline
May 16, 2014 - 1:34 pm

Mr Papa said
You haven't mentioned where you want to do this... It may vary...

Take a look at forum - toolbox - data inspector where you can display available global data based on page view...

User ID is available just need more specifics....

So basically I want to key off of the user that started the forum thread and do revenue share with them.

I'm going to be looking at this page to insert banner ads into the forum content section: https://simple-press.com/suppo.....de/page-4/

And if a user who i am doing rev share with starts the post, I want to create some code that is going to key of of their user ID and then include their ad code in the banners that are shown in the pages for the thread.

Does this make sense?

I don't think I need to use the data inspector (and don't know how) at this point?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 16, 2014 - 5:39 pm

still not sure what you want to do...  and why you didnt try the data inspector - very simple point and click and then displays globally available data on the page to you, including various user ids (logged in, current post, etc)...

you seem to be mentioning two different users in your discussion... the user who started the topic and the user adding a post...

and the topic you linked to referred to adding a banner at top... so if on fifth page of a topic, do you still only want access to the user id of the topic starter, which is currently not visible since you are on page 5?  on will you always ONLY be on topic view??

If all you want to do on any topic view page is grab the user id of the person who started the topic, you can get at it via:

$spThisTopic->topic_starter

if other, please explain in more detail what you want to accomplish...

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