Determining Buddypress Author (or any author) From Listings Page
This topic contains 9 replies, has 3 voices, and was last updated by Paolo 9 years, 11 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
November 24, 2015 at 7:56 am #61337
I am currently trying to associate each listing with the author of that listing somehow. I’m using the buddypress integration with the buddypress login, so I was hoping that each listing would be associated with that buddypress login in some way, so that I could add additional fields to the listing page based on the account of the person who made that particular listing.
I want to accomplish this code within the listing page, but I don’t have any idea how I would accomplish getting the author of the listing.
$author = get_the_author(); $vendor_user_login = get_userdata( $author ); echo do_shortcode('[wcv_recent_products vendor="' . $vendor_user_login . '" per_page=3]');Any help or direction would be greatly appreciated, thank you!
November 24, 2015 at 9:54 am #61345Activate the Listings Claim addon, and then at GD > Listings Claims > Options tab > Show link to author page on listings? > YES.
Let us know how you went.
November 25, 2015 at 3:57 am #61426Is there a way I can call on the author of the listing via Php? I installed the listings claim plugin and turned on the “show link to author page on listings” option but it made no change to the listings, still not seeing the author. Also, that isn’t exactly what I’m trying to do – I want to call on the author of the listing to then echo something from another plugin. This other plugin is using the buddypress login, also have geodirectory set to use buddypress login so I’m hoping that there will be a way to call on that author through php on the listing page.
November 25, 2015 at 11:51 am #61436You will see the author link there as soon you set the listing as “claimed” [edit the listing > Is claimed?].
I’ll get Paolo to have a look at the rest of your question.November 25, 2015 at 6:54 pm #61494Hi,
you can display the author of a listing with the regular wordpress function:
the_author();https://codex.wordpress.org/Function_Reference/the_author
Buddypress or WordPress, this doesn’t change.
Let us know how you went,
Thanks
November 25, 2015 at 7:03 pm #61496I’m sorry, I should have read the 1st question.
get_userdata returns an object.
https://codex.wordpress.org/Function_Reference/get_userdata
Depending on what the shortcode needs as parameter and I assumed it needs : username.
This should be something like:
$vendor_user_login->user_loginusing just :
$vendor_user_loginWill return the whole object and your shortcode will not work.
Let us know how you went,
Thanks
November 25, 2015 at 10:50 pm #61533Thank you so much for the help. The code still does not seem to work, I suppose I will need to speak with tech support from other plugin to fix that, but perhaps it is in the way I am trying to apply the code.
If I wanted this code to be executed on each listing page, would I copy the listing.php file and create a Geodirectory folder in my theme, copy the file there and then place this Php code anywhere in there? Apologies for my lack of knowledge, any help is greatly appreciated!
November 26, 2015 at 4:40 pm #61575Hi,
depending on where you want to add it, there are several hooks that can be used without copying templates in your child theme.
For example you could create a new tab with it: https://wpgeodirectory.com/add-a-new-tab-in-the-listing-detail-page/
Let us know how you went,
Thanks
December 7, 2015 at 4:20 am #62776Paolo,
I’m trying to use a shortcode within the new tab created in the link you gave me in previous post ^^
The shortcode is not working
This is what I’m trying to do
add_action('geodir_after_tab_content' ,'geodir_my_new_tab_content'); function geodir_my_new_tab_content($tab_index) { if($tab_index =='my_new_tab') {echo "[php snippet="1"][/php]";} }I have tried removing the quotes but it produces error, and with them the text of the shortcode is displayed. Plz help!
December 7, 2015 at 6:40 pm #62864You can’t echo a shortcode with php. You must wrap the shortcode with a do_shortcode function.
https://developer.wordpress.org/reference/functions/do_shortcode/
CHeck the User Contributed Notes at the bottom of the page with examples.
Thanks
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket