• Resolved academiadoaquario

    (@academiadoaquario)


    Hello there. I was in contact with Peepso about some modifications I need to make in my classified and they told me that this issue was supposed to be done by WPAdverts folks. Basically, I need to replace the username on Ad details page with link to user Peepso Profile. Is it possible to make? Maybe by an update or a CSS code?

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, WPAdverts has a adverts_tpl_single_posted_by filter which allows replacing the user name on Ad details page, if you just want to convert it to a URL then the code below will do that

    
    add_filter("adverts_tpl_single_posted_by", "my_adverts_tpl_single_posted_by", 10, 2 );
    function my_adverts_tpl_single_posted_by( $posted, $post_id ) {
        $post = get_post( $post_id );
        $author_url = get_author_posts_url( $post->post_author );
        $author_name = get_post_meta($post_id, 'adverts_person', true);
        return sprintf( __('by <a href="%s">%s</a>', "adverts"), $author_url, $author_name );
    }
    

    The code you can add in your theme functions.php file.

    Thread Starter academiadoaquario

    (@academiadoaquario)

    Hey, Greg! Thank’s for your answer! But there is only one problem – now the link displays specifically some other users name instead of the seller’s name (???)

    Example: Someone named Jonh signs up in Peepso and then go to WPAdverts to post some ad.
    Once published, in Ad details page, the name displayed is not Jonh, but the name of some other guy. Besides that, the link doesn’t lead you to that user profile. The url displayed is https://mysitename.com/author/Jonh when the correct url should be https://mysitename/profile/?jonh/

    Any tips on why this is happening?

    Thread Starter academiadoaquario

    (@academiadoaquario)

    If you want to test it by yourself, please try to post some Ad in https://academiadoaquario.com.br/classificados/

    You will see that the displayed name is not your name, but the name of some other guy. And when you click on it, you will not be redirected to any profile at all.

    Thread Starter academiadoaquario

    (@academiadoaquario)

    Update: The wrong name display bug is now fixed (I really don’t know why, I just deleted the code and pasted it again). But the link do not redirect the user to the sellers profile yet.

    Plugin Author Greg Winiarski

    (@gwin)

    Please check with PeepSo support what function you can use to get the URL to author profile, once you will know that you will need to update this line

    
    $author_url = get_author_posts_url( $post->post_author );
    

    or just ask them how to change the line above to return author profile URL to $author_url variable.

    Thread Starter academiadoaquario

    (@academiadoaquario)

    Thank you, Greg! I’ll will show this topic to their staff to see what they can do about it 😉

    Regards

    PeepSo has an option in configuration->appearance called “always link to PeepSo profiles”.

    It hooks into author_link filter, and when enabled it should work perfectly fine with WPAds, since Greg uses a get_author_posts_url which passes through that filter.

    Thread Starter academiadoaquario

    (@academiadoaquario)

    It worked just fine, thank you all! You people are amazing! 😀 😀 😀

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘replace the username on Ad details page with link’ is closed to new replies.