Support

Account

Home Forums Backend Issues (wp-admin) Capability Needed to show ACF

Solving

Capability Needed to show ACF

  • Hi,

    I’m working for a client that needs some advanced Capability features relating to a custom post type. A user needs to be able to edit their own posts but not anyone else’s. I’ve done this using capabilities.

    The issue I’m having is that ACF will not show (by this I mean when editing/creating a post) in the admin unless the role has the edit_others_* capability.

    Is there any way to change what capability is needed for ACF to display? Any help would be amazing.

  • Hi, did you ever figure out how to add ACF to users’ screens who do not have the “edit_others_*” capabilities?

    I’m getting the same problem with a custom post type.

    Thanks

  • I did, thanks to a fellow WordPress developer I know IRL.

    The problem in this clients case was that there was a piece of code in their theme that was adjusting the author using a line such as:

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

    in the child theme’s functions file. This was causing the ACF fields to disappear. I’m not 100% as to the reason, but it was definitely the cause. This code was used to remove the post the user didn’t own from view on the post listing screen.

    To solve the issue we just checked which page was being loaded before running the code using:

    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {

    A little low tech, but it was the only way to go for this client due to other reasons not related to this. You could try hooking the code onto ‘load-edit.php’ instead, but that is untested so YMMV.

    My advice though is to deactivate all the plugins and jump back to the 2014 theme. I realize it’s a pain if your CPT is in your theme, but it is IMO the best way to find exactly where your problem lies.

    Oh and as for the original question about capabilities. As far as I can see there are no restrictions on capabilities for ACF, if you can edit (just single edit, not edit_others) the CPT then you should be able to access the ACF fields too.

    Hope that helps you out.

  • Thanks, that was the same thing I just figured out.

    There was a plugin installed named “PBP Own post & media for Author” that used $wp_query->set( 'author', $current_user->ID );

    I didn’t resolve it completely, but I think I have a workaround. It is for WooCommerce, and I bought a $79 extension to accomplish what I was trying to do.

    I appreciate your time.

  • I’d thought it may end up being a similar issue.

    Glad you managed to get something sorted out though. 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.