My requirement is to create a survey in wordpress, and the user needs to log in before answering. But the login page uses our own business account, so we created a login page ourselves (using .net core). Therefore After logging in, we migrated to the wordpress survey page . But before entering the wordpress page, the wordpress side needs to check whether the user is logged in through a cookie. Go to the survey page if you have logged in, …
I read about 2 methods for initializing WordPress function outside of WordPress files so We can use these functions on any page or website outside the WordPress blog. Which one of these 2 methods is the correct one? What are the use cases for each method if both are correct? What is the deference between using one method or the other? Method 1: <?php define('WP_USE_THEMES', false); require('./wp-blog-header.php'); ?> Method 2: <?php define('WP_USE_THEMES', false); require('./wp-load.php'); ?>
I have this habit of installing a plugin with all my custom hooks, instead of writing a functions.php file with the same PHP code in it. That way I get the same functionality without the need of installing a child theme... So my plugin looks like this: <?php /** * Plugin Name: Custom Code * Description: Contains custom code needed by the website * Version: 1.1.5 * Author: Me * License: GPL2 * License URI: https://www.gnu.org/licenses/gpl-2.0.html * Text Domain: all-custom-code …
I created an external script to import json data into a custom post type that uses wp-load.php. Everything works fine but after every update I get the message Notice: map_meta_cap was called incorrectly. The post type EXAMPLE is not registered, so it may not be reliable to check the capability "edit_post" against a post of that type. Im calling the script inside a child theme and post_type_exists returns false but works fine... Ive seen a similar notice in a core …
I am trying to load WordPress options within a standalone PHP file. The file is located in /wp-content/plugins/plugin-name/file.php. I have used the following to open wp-load.php: if (file_exists('../../../wp-load.php')) { require_once ('../../../wp-load.php'); } Doing so outputs the following error: Fatal error: Cannot redeclare some_plugin_function() (previously declared in /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/plugin-name/class-frontend.php:5) in /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/plugin-name/class-frontend.php on line 12 Removing all code from class-frontend.php does solve the issue, but of course I need that file. class-frontend.php is not called within the standalone PHP file so am unsure …
I created a custom plugin. The plugin has a view log page. Here is my viewpage_template.php. First part is a query. The second part is a PHP for loop to present the data in a table. <?php // viewpage_template.php global $wpdb; // Get User ID $journal_author = get_current_user_id(); // this adds the prefix which is set by the user upon instillation of wordpress $table_name = $wpdb->prefix . "sg_entries"; $prompt_table = $wpdb->prefix . "sg_prompts"; // this will get the data from …
I am writing a custom php script and want to load the theme so it will look like a regular page. I tried the following. <?php define( 'WP_USE_THEMES', true ); require( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' ); $str = ''; get_header(); $str .= '<div id="primary" class="content-area">'; $str .= '<main id="main" class="site-main" role="main">'; $str .= 'Hello world'; $str .= '</main>'; $str .= '</div>'; echo $str; get_footer(); ?> It shows the header and footer. However the content appears without borders/margins. A regular page on …
I'm trying to prevent WP from loading all plug-ins when including wp-load.php, since I don't really need them nor the usual WP actions/filters. All I need is the WPDB class to query the database easily. I've only found an (old) solution that involves defining WP_INSTALLING to trick WP into not loading plug-ins, but I'm not sure if it still works on current versions and/or if there's a better way. (Background: I'm trying to optimize a simple autocomplete PHP script that …
so is it possible to define a folder outside the wp-$folders ? i created a html page and i want to use WordPress hooks and filters in it simply the WordPress PHP syntax im still learning php - and i dont know what file should i call to make it work my wordpress file system looks like wordpress | | |_ helloworld _ index.php ( contain php code + html - js - css ) |_ wp-admin |_ wp-content |_ …
Today I am stuck in a new problem using WordPress Theme Development. What I'm going to do is to open a Thumbnail image in a new separate child theme, when the user clicks on the anchor tag. Example: Click to Open Image and it redirects the user to the image on a separate theme file. Code Example for "single.php" <a href="PLZ MENTION CORRECT SYNTAX HERE" ); ?>">link to Another Page </a> Child Theme File "single-attachment.php" <?php /*** Template Name: Advertisement …
I have a standalone PHP script in my WordPress theme's directory that I run once every hour through a cron job (or manually if needed). All other WordPress functions are working except the update_option() function. A simplified version of my script looks like this: require_once('/path/to/site/wp-load.php'); $value = my_function(); update_option('my_option', $value); and in one of my theme's files, I am running the following code: echo get_option('my_option'); Nothing is printed, and a var_dump shows that the returned value is false. My wp-admin/options.php …
I am using cmb2 for frontend form submission with custom post type name 'form'. But can not upload image with that. the first step is: array( 'name' => 'Image', 'type' => 'file', 'id' => '_first_image', 'options' => array( 'url' => true, // Hide the text input for the url ), 'text' => array( 'add_upload_file_text' => 'Upload your image image', // Change upload button text. Default: "Add or Upload File" ), ), my form is: <form method="post" action="" id="form"> <div class="student-image"> …
If user is logged in to site/subsite, and you check this function: require(__DIR__."/wp-load.php"); var_dump(is_user_logged_in()); it returns true. However, if called from outside folder: require(__DIR__."/subfolder/wp-load.php"); var_dump(is_user_logged_in()); It doesn't recognize authorization. What are the acceptable ways to achieve that, without using REST-API? (I doubt it just needs pointing some sub-directory for cookie).
I created a plugin TESTPLUGIN and added it on wordpress admin menu. I can access the plugin from the admin menu just well. The problem I am having is how to link to another file within the plugin. The file members.php is loaded by the add menu callback function. In this members.php I want to add a link to show_member.php load a single member when the name of a member is clicked. Both files are under one directory. `<a href="<?php …
I have a PHP page at the same level as the template/theme on WordPress. I need to be able to get the current logged in user details from this page. I have tried this: require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' ); global $current_user; $current_user = wp_get_current_user(); var_dump( $current_user ); But it's returning nothing. 0 as user_id and nothing on the other fields. Am I missing something? UPDATE: This is the result of the var_dump: object Object]1object(WP_User)#79 (10) { ["data"] => NULL ["ID"] …
I’ve got a Nexus Theme (https://nexusthemes.com/) that stopped allowing me to edit through the frontend. Gives an “Error transferring data. Please try again later.” Console reports “Could not find wp-load.php (//) (), see nxs-ajax.php”“. It’s also breaking the theme’s contact form from submitting. This started happening ever since the site was moved to Flywheel’s new cloud platform (Google Cloud). Now with the cloud platform, they move wp-admin and wp-includes into /.wordpress/. So the theme can no longer locate wp-load.php. The …
Doesn't call user information to include "wp-load.php" in an external php file. <?php require_once( dirname( dirname( __ FILE __ ) ) . '/wp-load.php' ); global $wpdb, $user_ID; echo $user_ID; // reruns 0, always is_user_logged_in() // returns false, always ?> But I can check another one function will work. e.g. get_bloginfo('name') it will working. Note: I can try to require_once( dirname( dirname( __ FILE __ ) ) . '/wp-config.php' ); but results is same! What could be the reason for this? …
I have a file custom.php inside the WP root folder. My goal is to access the GLOBAL $menu variable that stores the admin menu items. In order to do that, I try loading the WordPress environment. <?php require $_SERVER['DOCUMENT_ROOT'].'/wp-load.php'; ?> After loading, I checked and made sure that the WordPress environment has been loaded. if (defined('ABSPATH')) echo "WP Environment loaded." Even when the wp-load.php is loaded, I am unable to access the global variable $menu which I can under a …
I'm using require_once(../../../../wp-load.php), which is the correct relative path to the file, but it doesn't work. If I use wp-blog-header.php instead, that works and enables me to use WP functions. Any ideas as to why wp-load.php isn't working? Thanks, Emir
When is wp_loaded initiated? Im trying to add function that downloads a big file for the plugin DB, and I need it to be executed whenever user/admin/unknown user get in the frontend, after the site is fully loaded, so that it would not be any delay with the site speed, and user experience. I use this script: // add update check when admin login if (is_admin()) { function wp_plugin_update() { include( plugin_dir_path( __FILE__ ) . 'wp-plugin-update.php'); } add_action( 'admin_init', 'wp_shabbat_update' …