Display Users Listings Shortcode?

This topic contains 13 replies, has 2 voices, and was last updated by  Paolo 8 years, 1 month ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #157315

    luxman
    Free User
    Post count: 38

    I’m creating a custom user profile page. I’d like to list the users current listings there, but I don’t see a shortcode or any code to be used. If this exists, please let me know. thanks!

    #157350

    Paolo
    Site Admin
    Post count: 31206
    #157398

    luxman
    Free User
    Post count: 38

    I added “[gd_listings post_author=”current”]” to the page but I see all the listings appearing.

    or is this supposed to be in the php template?

    #157402

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    who is the author of that page? It will show all listings entered by that author.

    Let us know if that’s not what happening.

    Thanks

    #157410

    luxman
    Free User
    Post count: 38

    This is being placed on a page, created by Admin.

    What I need is a direct php code I guess that checks to see who is logged in and then to display their listings.

    ——–

    The page I created is for members only, which displays their username/fields. I want to place a section under that which says “Your Listings.” But I need to have a code that does

    
    
    <?php
    $author = get_queried_object();
    $authorid = $author->ID;
    echo do_shortcode( '[gd_listings post_author="'.$authorid.'"]
    ?>

    something like that

    #157425

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    in that case you’ll need to add it to a template and get the currentuser ID with php.

    Thanks

    #157430

    luxman
    Free User
    Post count: 38
    
    
    <?php
    $author = get_queried_object();
    $authorid = $author->ID;
    echo do_shortcode( '[gd_listings post_author="'.$authorid.'"]'
    ?>

    is this the correct code to use?

    #157435

    luxman
    Free User
    Post count: 38

    never mind, got it.

    appears to work:

    
    
    <?php global $current_user;
          get_currentuserinfo();
    	  echo do_shortcode( '[gd_listings post_author="'.$current_user->ID.'"]')
    ?>
    #157439

    Paolo
    Site Admin
    Post count: 31206

    yep, that looks better.

    You are welcome 🙂

    #157440

    luxman
    Free User
    Post count: 38

    The only thing that sticks is the text “No listings found which match your selection.” This is fine for when a user searches for something, but this is being displayed in the user’s profile.

    Is there an if statement I can use to check if there are posts, if not then I have have different text?

    #157444

    luxman
    Free User
    Post count: 38
    
    
    <?php global $current_user;
          get_currentuserinfo();
    	  if gd_listings (post_author($current_user->ID)) == 0 { ?>
    		  <p>test</p>
    		   <?php } else { 		   
    	  echo do_shortcode( '[gd_listings post_author="'.$current_user->ID.'"]')
    <?php } ?>

    something like that?

    #157449

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I think it’s easier for us to add a parameter in the shortcode to allow you to change the default “no listings” text.

    I’ve asked to developers to let us know what is easier.

    We’ll let you know asap.

    Thanks

    #157493

    luxman
    Free User
    Post count: 38

    ok great thanks

    #158721

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    the developers added a new paprameter to the shortcode to add custom text for no listings found.

    This will be availble in the next release.

    Thanks!

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket