Support » Plugin: Gravity Forms Sticky List » Entries that both admins and entry creators can view

  • Resolved navyspitfire

    (@navyspitfire)


    Has anyone figured out how to create a list that both admins and entry creators can view?

    More specifically, admins can see all submissions from all members, while entry creates can only see their submissions. Thanks.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter navyspitfire

    (@navyspitfire)

    Solved. In plugin file class-sticky-list.php, around like 318 (// Get entries to show depending on settings), hide that whole if statement and replace with:

    $user = wp_get_current_user();
                    if(is_user_logged_in()) {
                        $user = wp_get_current_user();
                        if($user && !in_array( "administrator", (array) $user->roles )) {
                            $search_criteria["field_filters"][] = array("key" => "status", "value" => "active");
                            $search_criteria["field_filters"][] = array("key" => "created_by", "value" => $current_user_id);
                        } 
                        if (in_array( "administrator", (array) $user->roles )) {
                            $search_criteria["field_filters"][] = array("key" => "status", "value" => "active");
                        }
    
                        $entries = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
                    }
    corporatic

    (@corporatic)

    Hi thanks a lot for this,

    I need to allow admins and also EDITORS to be able to view entries.

    Any ideas?

    Waiting on your answer.

    Thanks in advance.

    Thread Starter navyspitfire

    (@navyspitfire)

    Maybe change line to:

    if (in_array( "administrator", (array) $user->roles ) || in_array( "editor", (array) $user->roles )) {

    Might be editors – no idea

    corporatic

    (@corporatic)

    Thanks mate!

    Thread Starter navyspitfire

    (@navyspitfire)

    It work?

    corporatic

    (@corporatic)

    Hi, more or less. I´m using this and it seems to work:

    if(is_user_logged_in()) {
    $user = wp_get_current_user();
    if (($user) && (!in_array( “administrator”, (array) $user->roles )) && (!in_array( “editor”, (array) $user->roles ))) {
    $search_criteria[“field_filters”][] = array(“key” => “status”, “value” => “active”);
    $search_criteria[“field_filters”][] = array(“key” => “created_by”, “value” => $current_user_id);
    }
    if (in_array( “administrator”, (array) $user->roles )) {
    $search_criteria[“field_filters”][] = array(“key” => “status”, “value” => “active”);
    }
    
    if (in_array( “editor”, (array) $user->roles )) {
    $search_criteria[“field_filters”][] = array(“key” => “status”, “value” => “active”);
    }
    
    $entries = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
    }
    
    By the way, perhaps you can help me this other issue. I want to show featured image on list but I don´t know where to place this code and how. Any ideas?
    
    jQuery(document).ready(function($) {
    cell = $(‘.stickylist-fileupload a’);
    cell.each(function(index) {
    image = $(this).attr(‘href’);
    $(this).html(‘‘);
    });
    });

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    Thanks again, mate.

    • This reply was modified 7 years ago by bdbrown.
    Thread Starter navyspitfire

    (@navyspitfire)

    In your child theme create a /js/ folder and create a .js file; copy the jquery code into that file. In your functions.php file copy this function if it’s not there already and replace the name of the .js file to whatever you named it. That will load the script into the footer of your site.

    corporatic

    (@corporatic)

    It worked!! I only had to change the class for this one .stickylist-post_image. THANKS

    One more question, for the first change (Entries that both admins and entry creators can view) is it possible to do it in an overrite file in child theme? I don´t like at all to modify plugin files…

    Thanks again.

    Thread Starter navyspitfire

    (@navyspitfire)

    Unfortunately I don’t know.

    corporatic

    (@corporatic)

    Thanks anyway, my friend. You have helped me a lot!!

    corporatic

    (@corporatic)

    Hi @navyspitfire, you are my only help in this forum…

    I have moved my wordpress to a subfolder and now EDIT option in stickylist is not working anymore… It still tries to call the old article in the root.

    Any ideas?

    Thanks a lot.

    Thread Starter navyspitfire

    (@navyspitfire)

    No idea. Recreate everything?

    bdbrown

    (@bdbrown)

    You might check the list here to make sure you didn’t miss any steps:
    https://codex.wordpress.org/Moving_WordPress

    corporatic

    (@corporatic)

    Thanks friends.

    Sticky List setting had lost the page to be shown, it is working now.

    Thanks a million

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Entries that both admins and entry creators can view’ is closed to new replies.