• Resolved gary_sweetman

    (@gary_sweetman)


    Hi,

    I have installed the ads by user addon from github and I just have one question if I may.

    The user url ends in the user ID (ie. ending in posted_by=1), is there any way which it can use the username instead?

    I have tried re-saving permalinks but this didn’t make any difference and I cannot see where in the code I may need to edit, I would appreciate it if you could help me out.

    Thank you.

    hopefully this is the last question and then I can get on and buy your paypal addon and get loads of members!

    https://www.ads-software.com/plugins/wpadverts/

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

    (@gwin)

    Hi, in order to have username in the URL you would need to edit the snippet code in a couple of places at least.

    Thread Starter gary_sweetman

    (@gary_sweetman)

    I have tried looking and broke it several times (backing up first so it could be reversed), but I seriously do not have a clue where I would need to edit.

    Could you please help or point me in the right direction?

    Plugin Author Greg Winiarski

    (@gwin)

    Sorry, but this is far beyond the free support offered here.

    Thread Starter gary_sweetman

    (@gary_sweetman)

    Sorry but how is showing how to “edit the code in a couple of places” far beyond? I have seen you offer far more on here, and I bet most of them didn’t buy a paid addon (as I have)

    Out of several support questions I have asked, I have resolved the majority myself or decided to go without with you only providing basic support on one (showing custom fields in admin by saying I had to use $cf).

    Oh well, looks like I’ll go without this one too

    Plugin Author Greg Winiarski

    (@gwin)

    Maybe it is not far beyond, but just beyond, i can help with some customizations of the WPAdverts package, but i do not help with customizing the free code snippets, especially if the change requires changing a snippet source code (ie. is not doable as a filter or action).

    Anyway … on lines 29, 104 and 120 replace

    adverts_request( "posted_by" )

    with

    get_user_by("login", adverts_request( "posted_by" ))->ID

    Change line 52 to

    $author = get_user_by( "login", adverts_request( "posted_by" ) );

    and on line 152 replace $post->post_author with

    get_user_by("login", $post->post_author)->user_login

    That should do it but i did not test it.

    Thread Starter gary_sweetman

    (@gary_sweetman)

    Now I get it!

    Thank you for your help, it mostly worked in that it changed the url to use the username, but it wasn’t adding the author name to the link on the single ad page (so it was returning “posted_by=”), but I (finally) figured it out.

    So anyone else looking to do this after a little playing about I discovered that the first three steps from Greg above are spot on, but to replace the last $post->post_author (on line 152 unless you have made further changes) with this instead:

    get_the_author(display_name)

    This seems to have done the trick!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can I use the username instead of user ID for links in "ads by user"’ is closed to new replies.