WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms Directory
[resolved] How user can see his/her posts only through this plug (8 posts)

  1. masterwoo
    Member
    Posted 2 years ago #

    What I want is that user once logged into my site should be able to see just his/her posts from his/her dashboard. The default role of user on website is "subscriber". Currently this plugin displays all entries in gravity form to everyone.

    I just want that user should only be able to see only his/her entries on the page.

    http://wordpress.org/extend/plugins/gravity-forms-addons/

  2. benjamingaier
    Member
    Posted 2 years ago #

    I had this problem myself. Just found the solution. Unfortunately I couldn't find a hook that could filter the entries so I had to insert is in the gravity-forms-addons.php:

    //
    // Or start to generate the directory
    //
    // Hack: added filter kws_gf_directory_lead_filter
    $leads = apply_filters('kws_gf_directory_lead_filter', GFDirectory::get_leads($form_id, $sort_field, $sort_direction, $search_query, $first_item_index, $page_size, $star, $read, $is_numeric, $start_date, $end_date, 'active', $approvedcolumn));

    I added the filter around GFDirectory::get_leads
    at about line number 1040

    then I added this code to my functions

    //Show entries of user logged in only
    
    add_filter('kws_gf_directory_lead_filter','show_user_entries');
    
    function current_user($content) {
    $current_user = wp_get_current_user();
    	return ( $current_user->ID == $content["created_by"]) ;
    }
    
    function show_user_entries($leads) {
    	return array_filter($leads, 'current_user');
    }

    I'm still very new to writing php. If someone knows a better solution..
    Hope it helps

  3. Zack Katz
    Member
    Plugin Author

    Posted 2 years ago #

    @benjamingaier - Thanks for the solution. I'll add a filter to get_leads() with the same name in the next update, coming this week.

  4. bwade231
    Member
    Posted 2 years ago #

    Where does this display at? in the back-end? Is there a way to attach it to profile in the fron-tend via custom link?

  5. Zack Katz
    Member
    Plugin Author

    Posted 2 years ago #

    That would take custom development.

  6. bwade231
    Member
    Posted 2 years ago #

    What kind of development would this take and what kind of rate?

  7. masterwoo
    Member
    Posted 2 years ago #

    Thanks a ton benjamingaier... I'll try this ... thanks once again

  8. benjamingaier
    Member
    Posted 2 years ago #

    You can now activate this functionality in the settings of the plugin under:
    Display entries only the the creator of the entry (users will not see other people's entries).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic