Hi,
the pending status is private meaning even users who are administrators cannot view those ads in the frontend, if you would like to change that you can add the code below in your theme functions.php file
add_action( "init", function() {
register_post_status( 'pending', array(
'label' => _x( 'Pending', 'pending status payment', 'wpadverts' ),
'public' => current_user_can("edit_pages"),
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'wpadverts' ),
) );
}, 1000 );
Hi Greg –
Unfortunately the code didn’t help.
I noticed that this issue also happens on Posts and Pages as well when WP Adverts is activated, but works fine when deactivating WP Adverts. I did a bit more troubleshooting and noticed that the problem happens when I have the Payments module enabled. When I deactivate the Payments module, I’m able to preview pending Ads, Posts, and Pages.
Hi,
the Payments module re-registers the “pending” status with a different “public” setting the code i pasted in the previous message should fix that.
If it does not then try changing “init” to “wp_loaded”, the code should run after the Payments module.
It should allow users with role Administrator and Editor to see the pages/posts with pending status
Unfortunately changing the hook from “init” to “wp_loaded” didn’t work. I tested this on a new page and new ad. The preview didn’t work.
I am testing both snippets now and they seem to work fine, please check the following:
- using phpMyAdmin see if the Ad you are looking at post_status set to “pending” or maybe is it some other status?
- if the user you are logged-in as has the edit_pages capability, or in the snippet just replace
current_user_can("edit_pages")
with true
for a while.
- before the
register_post_status(...)
add something like echo "????";
and refresh the page you should see “????” printed at the top of the page if the snippet is executed.
1.) The post_status column in the posts table shows a status of ‘pending’.
2.) I did that
3.) I did that and did see ‘????’ in the top left, so the hook is being executed
Still, I’m having no luck. I did look at the error log and saw some messages:
[02-Feb-2024 14:29:46 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/xxxxxxx/xxxxxxx/public_html/wp-content/plugins/wpadverts/includes/functions.php on line 1178
[02-Feb-2024 14:29:46 UTC] PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/xxxxxxx/xxxxxxx/public_html/wp-content/plugins/wpadverts/includes/functions.php on line 1179
[02-Feb-2024 14:30:03 UTC] PHP Notice: Function rest_validate_value_from_schema was called incorrectly. The "type" schema keyword for avatar_size can only be one of the built-in types: array, object, string, number, integer, boolean, and null. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /home/xxxxxxx/xxxxxxx/public_html/wp-includes/functions.php on line 6031
2) After making this change, do the pending items show in the preview?
The snippet seems to be running correctly on the site, i do not know why it isn’t changing how the pending status works.
Last thing you can try is open the wpadverts/addons/payments/payments.php go to line about 90 and comment our the code
register_post_status( 'pending', array(
...
) );
2.) Unfortunately the pending items didn’t show in the preview after making this change.
I tried commenting out the code in payments.php, but that didn’t work either.
My client said that for now he wants me to remove the ‘moderate’ option for the Classifieds Publish block, and maybe we’ll revisit this down the road. Do you want to close this thread or keep it open if we need to revisit?
I think you can close it for now, i have this noted and will look into it when i will find some free time.
OK, will close it for now. Thanks