Add Link to a Business Listing


Home Forums Front End PM PRO Add Link to a Business Listing

This topic is: Resolved
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #9595
    David
    Participant

    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.

    #9610
    Shamim Hasan
    Keymaster

    Please 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.

    #9613
    David
    Participant

    Brilliant!

    Thanks for the quick response!!

    #9616
    David
    Participant

    Would there be a simple way to make this only display for a given user role?

    #9619
    Shamim Hasan
    Keymaster

    You 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?

    #9622
    David
    Participant

    Only 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.

    #9625
    Shamim Hasan
    Keymaster

    Please let me know the role slug of those users (“business users” role slug) who have business listing.

    #9628
    David
    Participant

    I 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”.

    #9631
    Shamim Hasan
    Keymaster

    Please 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.

    #9634
    David
    Participant

    Awesome service and awesome plugin!

    Many thanks as ever for your quick replies 🙂

Viewing 10 posts - 1 through 10 (of 10 total)

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.