Skip Navigation

[Resolved] WP All Export Pro Cron job to hit Cron URL not working unless I deactivate Types

This thread is resolved. Here is a description of the problem and solution.

Problem:
You have a CPT created by Types, and deny read permissions to guests using Access to that CPT, then Export CRON Jobs run with the WP All Import plugin, do run, but do not export anything.

As soon as Access grants read permissions for guests on that CPT, OR Access is disabled, OR Access is restricting read access but you run the CRON manually in the Browser (logged in), the CRON properly runs and exports entries successfully.

Solution:
Set "read" to true for CPT guests permissions (CRON is a guest 🙂 )

There is one more solution, create a role copy of administrator, create a user and write a small plugin to open a session when WP runs from CRON. 'DOING_CRON' constant will help.

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 55 replies, has 3 voices.

Last updated by lindsayH 6 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1113646

I've just spent long time setting up the staging site for testing. Can't you use this one now?

I can't see that Access Control is installed on your test server, so I can export the access settings and send to you instead... but I'll need to be able to upload?

Can you send me a private link and I'll send you the staging URL... the credentials will be the same as those previously sent.

Sorry I missed where you suggested permissions, I mentioned here #1110376? Anyway that's what I'm hoping it is. I'm still doing some further testing yet.

Lindsay

#1113827

Actually, as you don't even have Access Control installed on the test server, not sure this could be the issue. Also having problems again, since the DNS populated and I've removed the mapping from my local hosts file. I'll need to continue testing.

Many thanks, Lins

#1114866

Lindsay, I apologise, but we have set up a server for this.
I asked to replicate the issue there, in a controlled and clean environment, and we can, of course, install any plugin you need to replicate this issue.
Even external ones, if it is about a conflict.

I cannot send our developers to debug an issue where I can not even outline the steps taken to make it happen or have a control over what is on the site, what server it is, and so on.

"so I can export the access settings and send to you instead... but I'll need to be able to upload?"

Perfect, that would work. I can (please let me know) install any plugin on that site (you too as you are an admin there)
I will install Access as soon as I have the file, then I can apply to the server and see what happens.

About this, I am not sure what you mean:
https://toolset.com/forums/topic/wp-all-export-pro-cron-job-to-hit-cron-url-not-working-unless-i-deactivate-types/page/4/#post-1113827

1. What is the issue with not having Access, if the issue is only replicable with Access? On the test server the CRON works, hence, not having Access can exactly be the reason of it working.
Please send me those settings or add the access to the next private reply so I can have a look at the staging site and grab the settings if needed

2. Not sure what the issue of DNS is, is this related to the CRON problem here? Toolset should not cause such issues, I would need to look at them in a new ticket, in case

3. I want to help you solve this, please do not spend too much time on the staging site, I think it is not needed for now (you said there the issue is replicated, and seemingly due to Access, I think we have the culprit)

Is this confirmed?
I began to think about permissions and therefore Toolset's Access Control. It appears that if I change Managed by Access in Access Control in the Employee's Work Type to Use the default WordPress read permissions (changed from Managed by Access) it does appear to work.

If so, it's clear that you need to add such rules to the live site to solve the issue, as read access is surely required to get a CRON/Export of any kind to work.
It may be that by managing with access you removed sensitive permissions that the plugin you use needs to make the export.
That can be answered only by supporters of that plugin (they might have a list of rights you need to make it work, we can then set Access so it works)

#1115525

The settings are now active on the test site here:
hidden link

Let's see how it does.

Currently the last CRON is:

Last run: 09/26/2018 12:02 am
1 Records Exported
Format: csv

My prediction is that it will fail, and as soon we give Guests the "read" permissions it will succeed, but we can let time speak the facts, there is no point in guessing.

Please let me know if you have any success on your end.

#1116305
Access Control - Employee Work Type.png

I seem to be able to run the cron job again. This is an example (trigger), but same for processing.

wget -q -O /dev/null "hidden link"

I am going to try on the live site, I'll let you know.

UPDATE: My staging site is working with 'Use the default WordPress read permissions' checked for Employees. My live site is not as this remains Managed by Access.

How can I give access to the Guest user? I'm unable to select in Access Control.

#1116984

Well, on the staging site I created for you, we have ourselves a nice confirmation of this:

Last run: 09/28/2018 12:02 am
0 Records Exported
Format: csv

It runs but doesn't get contents, since Access simply stops the process (I am satisfied with this, to be honest, this is very safe 🙂 )

I have now given "read" permissions to "Guests" to the Post Type "Senator Employees" on the test Site I shared earlier and will have to wait for the next CRON and it's results.
I would assume, this time we should have an export again, which would confirm, you need to let at least read the files.

However, on the other hand, I am also not sure, if this actually should be blocked and will need to ask the Access Developers to confirm this, after I confirm the exact steps (we are close)

Thanks for your extended patience.

How can I give access to the Guest user? I'm unable to select in Access Control.

Head to Toolset > Access > your_post_type > Control with Access > check the box for Read in the Guests row.

#1117062

Yes, checking the Read access for Guests appeared to have worked on my live site.

I am happy... do you want me to close?

Thank you for all your help. Much appreciated.

Lindsay

#1117098

If you do not mind I would like to take this to a technically and scientifically (if you want so) explained end.

I don't like calling off problems just because it works. I would wait until I can confirm it's due to Access rules (pretty much sure) and then I want to have a word with the Developers, clarify why this happens (CRONs are after all server side running things).

Then I can update you, and we may even update the DOC, this is a nasty detail if confirmed, which can be easily overseen.

I'll keep it open, thanks for confirming that it works on your end as well with the changed Access Settings.

#1117611
Last run: 09/29/2018 12:02 am
1 Records Exported
Format: csv

Remains to get a "reason" why this exactly happens from the Access Developer which I hope to receive Monday

After, I'll look to document this somehow.

#1119037

1. By default, WP CRON runs the scripts as a guest.

2. When a user runs a CRON Job from a browser, it takes the current logged in user's session (hence, is higher than a guest)

3. If Access removes rights to read from guests, it is a success confirmation that a CRON fails, if not logged in. It's good, expected.

As a solution, you will either need to enable read permits for guests in that Post Type or create a copy of the role "administrator", then create a user with that role, and write a small plugin to open a session with that user, when WordPress runs from CRON.
'DOING_CRON' constant will help to craft such a logic:
https://developer.wordpress.org/reference/functions/wp_doing_cron/
hidden link

We can't assist with this, but we can confirm that the issue is fully expected and an effect of (working) control of Access over the content.

PS.
I filed a request, that would allow disabling Access rules totally for CRON jobs, as a visual option in Access.
I would suggest to upvote it, so it gets more chance for implementation.
https://toolset.com/feature-request/optionally-disable-the-access-rules-when-cron-jobs-are-run/
To upvote:
https://toolset.com/feature-request/ and run a search for the above feature (It's enough if you query for "CRON"):
(note that it'll take some time for the feature to be online so best is, you check in 24 hours to upvote it)

We can close!

Thanks for your continued patience.

#1119055

My issue is resolved now. Thank you!