Solved by:
//Check and set/unset user to able the script to run as admin
wp_set_current_user(1);
$link = get_edit_post_link($post_to_private->ID);
wp_set_current_user(0);
Thanks Sally CJ,
Related Posts:
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- How to use wp-ajax in wp-cron
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- How make a php script run only with wp-cron
- Setup wp_schedule_event within a custom plugin
- get_users(); Is an Undefined Function When Used in Cron Job
- Switch from wp-cron to a server cron job
- i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
- How to properly insert data into custom table via plugin
- Keep one user logged for a year?
- Searching users with WP_List_Table plugin
- Generate custom output for page/URL in a plugin
- WordPress widget / plugin….fields not appearing in my widget
- How to list the Hooks and order of execution in current loading page? [duplicate]
- How to turn off email you receive when registered?
- Multi step form, custom plugin
- How to send “Location” header on plugin form submit event?
- Add jQuery to WordPress page
- wp_schedule_single_event function not working
- Custom Shipping method not showing in checkout
- From where come that JS files in ?
- Difference between register_block_type & wp.blocks.registerBlockType
- Can’t get custom posts of taxonomy to show
- Can I check plugins and themes for PHP 5.6 ahead of global PHP server Update
- Improving a Stackoverflow “inspired” badge system to display badges in author page
- how to include a simple jquery file into a wordpress plugin
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- How to get member list based on role by using buddypress?
- Missing argument 3 for wp_register_sidebar_widget()
- How to Include a Loop Template File in a Plugin
- get shortcode value
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Storing Options in a Shortcode
- How can I get WordPress to save comments in markdown format?
- Shortcode button dosent work for all posts. Work for first post only
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Add Product Subtitle to Woocommerce Product Page
- Display data on Word Press site posts and pages from mysql table
- Plugins Page invisible / white
- Redirection of users away from wp-admin (but not administrators)
- code is working properly in Core PHP but writing coding in WordPress
- Most efficient way to use classes to create admin pages using Settings API
- CMB2 toolkit: Compare 2 Dates and validate the Time
- PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback Error without any function name
- Custom WPBakery elements not displaying in WP admin
- How can I fix the mixed content problems of the kk star ratings plugin?
- Basic Object Oriented plugin question
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- Adapt PHP form action for WordPress?
- All sites themes functions.php have been changed
- WordPress + PHP + IIS + PHP Fatal error: require():
- admin-ajax.php warning max input vars exceeded on layered pop plugins [closed]
- Individual testimonial taxonomy not displaying (white screen)
- Adding regex filter to feedwordpress
- Perform internal redirect in WordPress?
- How to prevent plugins from loading jQuery
- Using TinyMCE in plugin?
- Notify comment author upon reply
- WordPress get_avatar function not correct working
- How passing values to construct function with Actions?
- add_action into another add_action not working
- Using ‘mysqli_connect’ ‘crashes’ WordPress client-side
- Add User Role: Pre-saved in User-Meta [SOLVED]
- How to make a dynamic css class whose name changes every visit to confuse scraper
- WordPress custom post type image in RSS
- Add logo to admin menu in my plugin
- Get data from wp_posts of mysql in to variables of wordpress-php script
- WordPress plugin won’t create custom tables
- Cannot access empty property error in Advanced Access Manager
- Trying to get property of non-object wordpress error message
- Advertising: Every page refresh counts as 3 ad impressions
- WordPress Cache delete on plugin uninstall
- How to create repeater field manually, without plugin (ACF Pro)?
- Woo-commerce Update price as a Bulk from My offline software export
- How to disable login in iframe which is hosted in same domain?
- Display Author name PHP (Selfmade Plug-IN)
- Display top level parent category as a single product body class (Woocommerce)
- Allow a particular user to access a particular plugin?
- WordPress Standard Fix Errors
- How do I use a plugin’s shortcode attribute value in another function?
- Change the address of the music player if not available
- WordPress hide post from custom post-type on a single page
- update_post_meta is not working for me when I use e.preventDefault for update button
- Use modulo condition in ACF repeater Field
- Add a WooCommerce Product Variant with attributes programmatically
- Scheduled cron event removed from list automatically after sometime
- Site broken by unedited php?
- Help with customising love it plugin (use within foreach)
- Plugin communication between sites that use it?
- What is the process for reimplementing a back up WordPress?
- Showpost and last
- Undefined variable _POST
- How to add custom html to the Media > Attachment Details modal?
- Displaying Category Feature image on loop
- Sort posts by Date (DESC) and by ACF: active_inactive (ASC)
- How to fix Fatal error: Cannot redeclare get_cli_args() in class-wp-importer.php
- How to fix template and image buffering issues on website [closed]
- PHP FATAL ERROR
- WordPress broken dashboard with ninja-shell text
- Fields are not displayed on front end under custom php code in Advanced Custom Fields and Flexible Content field WordPress