Skip Navigation

[Resolved] I want user to be able to edit custom fields within CPT using Access

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Author
Posts
#2042763
Edit-Horse-for-Sale-‹-Select-Geldings-For-Sale-—-WordPress.png
Edit_Horse_for_Sale_‹_Select_Geldings_For_Sale_—_WordPress.png

Tell us what you are trying to do?
I created a CPT (Horses for Sale) and a Toolset Form so users can enter their own info. With Access, I have set it so that users (set up as subscribers) can edit their own CPT, but when they access it on the dashboard, the custom fields don't show. See the images below to see what a subscriber can see vs what an admin can see.

#2043073
screen-options.png

Hi, I'll be glad to help here. It looks like there could be a configuration issue in Toolset Access, or possibly a configuration issue in the post editor screen. Please provide answers to the following questions:

- Is this field group active in the post editor Screen Options? When logged in as a subscriber, please edit the same post shown in your screenshot here and open the Screen Options tab in the top right corner of the screen (see attachment screen-options.png). Please take a screenshot and share it in your next reply so I can see the options available in the Screen Options tab for a Subscriber User.

- What are the Access Control settings for this field group? Go to Toolset > Access Control and open the Types Fields tab. Toggle open the Horses for Sale Details panel and take a screenshot so I can see the configurations for this field group.

- Are there any conditional display rules applied to this field group? Go to Toolset > Custom Fields and edit the Horses for Sale Details Field Group in the Post Fields tab. Toggle open the panel "Settings for Horses for Sale Details" and take a screenshot so I can see the conditional display settings, if any, applied to this field group.

- Does this problem occur with only Toolset Types and Toolset Access active? Please temporarily deactivate any custom code snippets in Toolset > Settings > Custom Code, temporarily deactivate all 3rd-party plugins except Toolset Types and Toolset Access, and activate a default theme like Twenty Twenty One. Test again. If the problem is resolved, reactivate your custom code snippets, other plugins, and your theme, one by one, testing each time you activate another component, until the problem is resolved.

#2043131
post-field-group.png
access-control-settings.png
screen-options.png

Screen Options - not available there. See attachment
Access control -See attachment
Conditional display - no See attachment
Custom code - there is no custom code.

One weird thing I discovered as well is that a subscriber can only edit it while it's "pending review". Once the post type is published, the subscriber can only view the item, but not edit it.
The form where subscribers can submit the CPT is on a private page, but anyone can view the CPT's once they've been published. I wouldn't think that would have anything to do with editing the CPT in the backend.

Thanks for your help!

#2043267

Okay thanks for the additional information. I didn't get your feedback on the outcome when you deactivate other plugins and activate a default theme - were you able to perform this test?

One weird thing I discovered as well is that a subscriber can only edit it while it's "pending review". Once the post type is published, the subscriber can only view the item, but not edit it.
I assume you're talking about editing directly in wp-admin here, not in a front-end Form. In your screenshots from wp-admin, I can see Litespeed caching is implemented here, and it's possible there are other caching systems implemented that I am not aware of. Let's try to purge that cache. First, please go to Toolset > Custom Fields and resave the Horses for Sale Details post field group settings to trigger an update of the database information for these options. After that, clear all Litespeed caches as well as any other server-side caching mechanisms you may have in place (object caching, opcache, memcache/memcached, varnish, redis, etc.). I think there is a Litespeed menu in the top admin bar (hover over the diamond-shaped icon next to "Themify Cache" and flush all available caching mechanisms). You may need to ask your hosting company if there are other server-side caching systems in place, and find out how to flush those caches manually.

If disabling other plugins, activating a default theme, and flushing server-side caches does not solve the problem, we should check next to see if any server-side errors are logged when visiting this page as a Subscriber. If you are not familiar with server logs, I can show you how to activate one temporarily. These instructions are written for a standard wp-config.php file. Edit your wp-config.php file and look for

define('WP_DEBUG', false);

Change it to:

define('WP_DEBUG', true);

Then add these lines, just after the WP_DEBUG line:

define('WP_DEBUG_LOG', dirname(__FILE__) . '/error_log.txt');
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
define('WP_DISABLE_FATAL_ERROR_HANDLER',true);

If your wp-config.php file has any of these items already defined (this would be a non-standard wp-config.php), you must comment out or modify the original definitions to prevent an error for duplicate definitions.

After updating wp-config.php on the server, log in to wp-admin as a Subscriber and edit the Horse for Sale post again. If any server-side errors are triggered during this process, it will create an error_log.txt file in your site's root directory. Use FTP to look for this file in the same directory as wp-config.php. You may need to click "Refresh" in your FTP browser to see a new file appear. Please download this file to your computer, open it in any text editing software, and copy its contents and paste them in your next reply. You can delete any private details you don't want to share in the output. Once you are done, you can revert the changes you made to wp-config.php and delete the log file using FTP.

If no errors are generated the the problem is not resolved, I'll need to take a closer look.

#2045085

Yes, I deactivated all the plugins except the Toolset plugins and changed to the 2021 theme, and still had the problem. I also flushed the server cache. I also ran the debug as you suggested and am pasting the results here. I hope they help. Thank you!

[05-May-2021 13:51:05 UTC] PHP Warning: imagecreatefromstring(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:51:05 UTC] PHP Warning: imagecreatefromstring(): Passed data is not in 'WBMP' format in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:51:05 UTC] PHP Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:55:32 UTC] PHP Warning: imagecreatefromstring(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:55:32 UTC] PHP Warning: imagecreatefromstring(): Passed data is not in 'WBMP' format in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:55:32 UTC] PHP Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:57:47 UTC] PHP Warning: imagecreatefromstring(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:57:47 UTC] PHP Warning: imagecreatefromstring(): Passed data is not in 'WBMP' format in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 13:57:47 UTC] PHP Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 14:08:05 UTC] PHP Warning: imagecreatefromstring(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 14:08:05 UTC] PHP Warning: imagecreatefromstring(): Passed data is not in 'WBMP' format in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 14:08:05 UTC] PHP Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 14:30:54 UTC] PHP Warning: imagecreatefromstring(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 14:30:54 UTC] PHP Warning: imagecreatefromstring(): Passed data is not in 'WBMP' format in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277
[05-May-2021 14:30:54 UTC] PHP Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in /home/selectge/public_html/wp-content/themes/themify-ultra/themify/img.php on line 277

#2045241

Unfortunately I don't see anything in these logs that seems relevant to the custom field display issue. At this point I think it would be best for me to try to create a clone of your site using a tool like Duplicator or All-in-One WP Migration, then try to replicate the problem in a clone of your site installed on my local environment.

If that's okay with you, please provide login credentials for both an admin User and a Subscriber User in the private reply fields here so I can see the problem. If I am able to see the problem as the Subscriber, I will log in as admin, install one of the cloning plugins, and create a clone of the site so I can run additional tests in my local environment.

#2046269
Screen Shot 2021-05-06 at 10.09.37 AM.png

When I try to log in using this admin information, I see an error that the User has not confirmed their account. Can you help me get access?

#2046279

I apologize. I swore I had confirmed you. All set now!

#2046685

Okay it seems there are two issues:
1. You would like to allow Subscribers to edit published Horses for Sale posts, but they cannot currently do so. Once the post is published they lose editing capability.
2. Types custom fields are not displayed in the Horses for Sale post editor screen for Subscriber Users.

Regarding issue 1, Subscribers and Contributors are typically locked out of posts once they are published. It's something of a catch-22 from WordPress, because if you do not grant these Users the ability to publish posts directly, you cannot also grant them the ability to unpublish published posts, which is what you would effectively be doing here by allowing them to edit published posts and send them back through workflow for approval. I've investigated and found a case in the past where this problem was discussed for Contributor Users, who typically have higher permissions even than Subscribers. I investigated this with our developers in the past and what you're experiencing is the expected behavior here for WordPress. Unfortunately we don't have a simple override available in Access, or a custom code snippet available to override this feature when Access controls the custom post type:
https://toolset.com/forums/topic/contributors-should-be-able-to-edit-their-own-content-but-they-cant/
However, a workaround in this case is to add an Edit Post Form that sets the post status to Pending Review. You could allow Subscribers to edit their own published Horses for Sale posts using this Form with Access Control, and it would set the post status back to Pending Review, effectively unpublishing the post and returning it to the Pending Review workflow.

Re #2, custom fields are not displayed to Subscriber Users when creating new or editing existing Horses for Sale posts (in Pending Review or Draft Status). In my local test environment, this seems to be a multi-way plugin conflict. If I have Toolset Types, Access, Views and Forms active along with the WP Members plugin, the custom fields are not displayed. If I deactivate either Toolset Forms or WP Members, the custom fields reappear. May I try this test as well on the live site to see if the behavior is replicable there? If so, I can escalate this problem to my 2nd tier team for additional investigation.

#2046687

Thank you so much for all this research! Yes, feel free to turn off the WP Members or Toolset Forms plugin temporarily.

#2047023

Okay thanks, I have run that test on your live site and I can confirm that the custom fields return if I deactivate either the Toolset Forms plugin or the WP-Members plugin temporarily. I have reactivated both of those plugins and I'm finished testing here.

I think that gives me enough information to escalate this issue to my 2nd tier support team for further investigation. I did a quick search in the forums and found another ticket mentioning this plugin and a similar problem displaying custom fields in the backend editor, but no real solution was mentioned:
https://toolset.com/forums/topic/custom-fields-of-types-not-found-in-views/

I'll let you know what I find out from my 2nd tier support team. For now, it seems like the Forms workaround I mentioned is the most practical solution. If we can produce a better workaround or a software patch file, I will let you know as soon as I can.

#2048145

I appreciate this, and would like to take advantage of your workaround, but I'm unsure what to do. I've been trying to follow the forums and documentation, but don't seem to be getting anywhere. I tried adding an "edit" button to the bottom of the CPT, but it doesn't show for subscribers or contributors. I can see it as an admin. Then you say something about "add an Edit Post Form". I can't find out how to do that. I have the form for subscribers to submit a horse, but don't understand how set up something for them to edit. Can you point me in the right direction? Or perhaps there is some other membership plugin that doesn't conflict that I can install instead? Thanks again for your help!

#2049401

We have documenation available for editing content in Forms here:
https://toolset.com/course-lesson/front-end-forms-for-editing-content/

Information about allowing Users access to specific Forms:
https://toolset.com/course-lesson/controlling-access-to-front-end-forms/

#2051021

Actually, this is exactly what I needed and will be using it a lot. Thank you!
My issue is resolved now. Thank you!