• Resolved anilreddy0102

    (@anilreddy0102)


    My site has 50 users. All of them upload the data. Now I want to show the entries of a set of users to a single user who is not a part of that set. Suppose I want to show the entries of Users X,Y,Z to user A. I know I can show this by putting multiple shortcodes in a page. But is there a way where I can show all the entries of multiple users in a single table?

    https://www.ads-software.com/plugins/gravity-forms-sticky-list/

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

    (@fried_eggz)

    Yes. You can use the filter_entries filter to remove all entries that do not belong to one of the specified users:

    Something like this:

    add_filter('filter_entries','hide_some_rows' );
    function hide_some_rows($entries) {
        foreach ($entries as $entryKey => $entryValue) {
            if ($entryValue["created_by"] != "1" && $entryValue["created_by"] != "2") {
                unset($entries[$entryKey]);
            }
        }
        return $entries;
    }

    The above code, when placed in functions.php, would hide all entries that are not created by user ID 1 ocr user ID 2

    Thread Starter anilreddy0102

    (@anilreddy0102)

    Thanks for the prompt response. But I would need to create multiple sets. Like… Entries from X,Y,Z will be showed to A; M,N,O will be showed to B etc., Is that possible?

    Plugin Author fried_eggz

    (@fried_eggz)

    Yes. You can expand the example above to check for what user is logged in.

    This is however outside the scope of Sticky List. Sticky List provides a way to display entries from a form. For whom and what you want display is a logic that would have to be added on top of this plugin.

    Thread Starter anilreddy0102

    (@anilreddy0102)

    Can I add this code to any php executing plugin or it has to be added to functions.php only?

    Plugin Author fried_eggz

    (@fried_eggz)

    I suppose you could. But what’s wrong with functions.php? ??

    Thread Starter anilreddy0102

    (@anilreddy0102)

    My theme is showing some errors when this code is pasted in functions.php file

    Plugin Author fried_eggz

    (@fried_eggz)

    Ok. What errors?

    Plugin Author fried_eggz

    (@fried_eggz)

    Since you have not posted back I’ll make this topic as resolved. Feel free to reopen in needed.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Showing Entries to LoggedIn Users’ is closed to new replies.