Current status: Solved. . Done
Custom Type and Custom User
  • Seems that I'm not able to see any of my acf metaboxes when logged as a custom user, all these custom fields belong to a custom type post, I'm not sure if I'm supposed to enable some capabalities when registering my custom post typet to make acf work, I'm using Adminimize and Members plugin too but even when I deactivate these plugin still w/o result, actually looks like if I was editing a common post
    function codex_custom_init() {
    register_post_type( 'informativas',
    array(
    'labels' => array(
    'name' => __( 'Informativas' ),
    'singular_name' => __( 'Informativas' )
    ),
    'public' => true,
    'has_archive' => true,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt'),
    'taxonomies' => array('post_tag'),
    )
    );
    }
    add_action( 'init', 'codex_custom_init' );


    And yes I did set a rule when creating my field group to display only on my custom post type

    I'm attaching a screenshot of which plugins i'm currently using...

    I'm pretty sure this problem might be related to user capabilities but I can't manage to find which capabilitie set by default on members plugin should make things work, I have set, for my custome user, edit, create, publish and read capabilities

    Thanks in advance


    Update #1

    I tried by playing with default wordpress roles, seems that only editor is able to see my acf metaboxes on my custom post type, I don't think is related to Members or Adminimize now

    Update #2

    Ok I manage to find my problem, seems that custom function to only display user posts and not others cause this problem....
    function posts_for_current_author($query) {
    global $user_level;
     
    if($query->is_admin && $user_level < 5) {
    global $user_ID;
    $query->set('author', $user_ID);
    unset($user_ID);
    }
    unset($user_level);
     
    return $query;
    }
    add_filter('pre_get_posts', 'posts_for_current_author');


    if there's anyone knowing how make this custom function to work with acf would be really helpful, right now i'll be testing out too! thanks again.
    Imagen 2.png
    235 x 698 - 51K
  • Hi @iFerD

    I have marked this topic as solved as I believe you have solved the problem caused by a custom function.
    Was this function part of your functions.php or another plugin?
  • I think I might have the same problem.

    But this code does not fix my problem. Also I have restricted the user role from accessing, reading posts published by others which is a requirement for my project.
  • Ok I had the same problem :) nothing to do with ACF

    I was using a function similar to @iFerD I commented out the following line and it worked.

    $wp_query->set( 'author', $current_user->ID );

  • I've the same problem, but right now I think the issue is not solved, as I need this function on my website. Need to show only current user posts and not all other authors. @iFerD, could you finally find a solution?

  • umm try with

    function ik_eyes_only( $wp_query ) {
                if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
                    if ( !current_user_can( 'level_5' ) ) {
                        global $current_user;
                        $wp_query->set( 'author', $current_user->id );
                    }
                }
            }
     
            add_filter('parse_query', 'ik_eyes_only' );
  • Thanks a lot @iFerD !!!! It works for me!

    I saw this way to display only current user posts, but didn't even try it. The rush didn't make me read it enough, so I didn't see the difference from the one I was using (the same you posted at the beginning of this discussion. Thanks again I owe you everything :-D