Home › Forums › Front End PM PRO › Add Link to a Business Listing
- This topic has 9 replies, 2 voices, and was last updated 7 years, 11 months ago by David.
- AuthorPosts
- January 5, 2018 at 12:10 am #9595DavidParticipant
Hi,
I want to add a link somewhere in the viewmessage.php which will provide a link to a user’s business listing in Business Directory Plugin.
The URL for the business listing is https://mysite.com/business-directory/(user_nicename)
My experience with php lets me down here I’m afraid. If you could tell me how to produce that link to add to the viewmessage.php I would be very happy 🙂
Thanks for your time.
January 5, 2018 at 4:23 pm #9610Shamim HasanKeymasterPlease add following code in your theme’s (child theme’s if any) functions.php
add_action( 'fep_display_after_message', function(){ echo '<a href="' . esc_url( home_url( 'business-directory/' ) ). get_the_author_meta('user_nicename') . '">' . get_the_author_meta('display_name') . '</a>'; });It will add a link to user’s business directory in bottom of every message.
January 5, 2018 at 5:10 pm #9613DavidParticipantBrilliant!
Thanks for the quick response!!
January 5, 2018 at 5:37 pm #9616DavidParticipantWould there be a simple way to make this only display for a given user role?
January 5, 2018 at 7:45 pm #9619Shamim HasanKeymasterYou want to display only if message user is given user role or who is seeing that user is given user role?
Which role you want to display?January 5, 2018 at 8:01 pm #9622DavidParticipantOnly half of the users have a business listing – “business users”. The other half are “clients” and do not have one. So instead of having a link below the “client” message which will lead to a 404 error I was thinking to change the user roles and so only display a link below the messages of “business users” that have a business listing. Then I want both “business users” and “clients to be able to see the link below the “business user” message.
January 5, 2018 at 8:40 pm #9625Shamim HasanKeymasterPlease let me know the role slug of those users (“business users” role slug) who have business listing.
January 5, 2018 at 9:20 pm #9628DavidParticipantI haven’t created the role yet as I was waiting to see if it could be done. So to keep it simple we can call them “Business”.
January 5, 2018 at 9:46 pm #9631Shamim HasanKeymasterPlease add following code in your theme’s (child theme’s if any) functions.php
add_action( 'fep_display_after_message', function(){ $authordata = get_userdata( get_the_author_meta('ID') ); if( in_array( 'administrator', $authordata->roles ) ){ echo '<a href="' . esc_url( home_url( 'business-directory/' ) ). get_the_author_meta('user_nicename') . '">' . get_the_author_meta('display_name') . '</a>'; } });Change ‘administrator’ to whatever your user role is. For testing purpose i have used ‘administrator’ so that you can check that only ‘administrator’ role users link will show.
January 5, 2018 at 11:53 pm #9634DavidParticipantAwesome service and awesome plugin!
Many thanks as ever for your quick replies 🙂
- AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.