• Resolved wpsupport2248

    (@wpsupport2248)


    I’m needing to display entries only from specific logged in users.

    Am I meant to just add the following OR have I missed some other process?

    I have added the below to a page and it shows the View for ALL forms plus Edit for the logged in User. I ONLY want to show the forms for the logged in user…

    [stickylist id=’1′ user=’” . $user_id . “‘]

Viewing 13 replies - 1 through 13 (of 13 total)
  • rockysroad99

    (@rockysroad99)

    I believe your only option is all logged in users on the drop down list
    Show entries in list to:

    I am not sure adding that shortcode to a page will get you what you need.

    Thread Starter wpsupport2248

    (@wpsupport2248)

    In the More Detail it clearly states

    “Sticky List is an add-on for the WordPress plugin Gravity Forms that lets you list and edit entries from the front end. You can display a list on the front end where users can view, delete and edit submitted entries.”

    It says further down “Choose who can se the list; specific role, entry creator, all logged in users or anyone.”

    In the USAGE section it states

    “To use this in a template file, for example on the user profile page (make user that the variable $user_id holds the ID of the user who’s profile is being viewed): echo do_shortcode( “[stickylist id=’1′ user=’” . $user_id . “‘]”);

    How do I achieve this?

    Plugin Author fried_eggz

    (@fried_eggz)

    @wpsupport2248, in your php template file (that is used to display the form) put this:

    
    $user_id = get_current_user_id();
    echo do_shortcode( “[stickylist id=’xxx′ user=’” . $user_id . “‘]”);
    

    where xxx is the ID of your form.

    Rather than the logged in user, is it possible to have all users in a drop down and run the stickylist query based upon which user is selected?

    Plugin Author fried_eggz

    (@fried_eggz)

    @frjoel on a per form basis?

    Please describe your use case in more detail.

    There are several ways to achieve what (I think) you are trying to do. One is in the shortcode (like in the example above), another is using a filter, a third is the custom capabilities.

    Thanks for the reply!

    So I have several forms that I need all users to fill out each year. In order to see which forms a user has completed and which ones they haven’t, right now I have a page with a heading and a sticky list for each form. Those forms that the logged in user has completed show an entry, and those that they haven’t just show “please complete this form”.

    Right now I have to log in as that person (or switch users to them with a plugin) to tell which forms have been completed. It would be nice to just select which user I want to see entries from in a drop down rather than switching users.

    I hope that makes sense? Thanks for your help.

    Plugin Author fried_eggz

    (@fried_eggz)

    You could create a dropdown that lists all users and when changed it does a post request passing the user id of the selected user.

    You could then add your lists like so:

    $user_id = $_POST["user_id"];
    echo do_shortcode( "[stickylist id='1' user='" . $user_id . "']");
    echo do_shortcode( "[stickylist id='2' user='" . $user_id . "']");
    echo do_shortcode( "[stickylist id='3' user='" . $user_id . "']");

    Thank you for that. I unfortunately am not much of a programmer so that’s a bit out of my range. Could I tip you on Paypal to put it all together for me?

    Plugin Author fried_eggz

    (@fried_eggz)

    Something like this should work:

    <form action="./" method="post">
    	<select name="user_id">
    
    	<?php
    	$users = get_users();
    	foreach ($users as $user) {
    		echo "<option value='" . $user->data->ID . "'>" .  $user->data->display_name . "</option>";
    	}
    	?>
    
    	</select>
    	<input type="submit" value="show">
    </form>
    
    <?php
    $user_id = (isset($_POST["user_id"])) ? $_POST["user_id"] : 1 ;
    echo do_shortcode( "[stickylist id='1' user='" . $user_id . "']");
    echo do_shortcode( "[stickylist id='2' user='" . $user_id . "']");
    echo do_shortcode( "[stickylist id='3' user='" . $user_id . "']");
    ?>

    Put this in a template file for the page that you want to use it on. Make sure to change the id of the lists above to those that you want to show.

    Thanks very much. Unfortunately the dropdown user selection doesn’t stick. Once a user is selected and the form submitted, the dropdown defaults back to the first user in the list (while still only displaying the form entries of the currently logged in user).

    Plugin Author fried_eggz

    (@fried_eggz)

    Try changing the setting “Show entries in list to” and select “Entry creator”

    That did it! Thank you! What’s your paypal?

    Plugin Author fried_eggz

    (@fried_eggz)

    You can find the donate link on the bottom of the Sticky List settings page. But if possible, I would prefer if you wrote a review of this plugin if you find it useful. Reviews can be left here: https://wordpress.org/support/plugin/gravity-forms-sticky-list/reviews/. Thank you!

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Shortcode Sticky list $user_id logged in users’ is closed to new replies.