is_user_logged_in() Not Working on Some of My Plugin PHP File
-
Hello. I made a WordPress plugin with php files. However some of my php files can use is_user_logged_in() and some are not. Anyone here can help me.
Here is the code of my main plugin file(pluginstart.php)
<?php
/** /public_html/wp-content/plugins/SLMS/pluginstart.php */
/**
* Plugin Name: SLMS
* Description: School library Management System shortcodes.
* Version: 1.0.1
* Author: Marvin
* Author Email: [email protected]
* Author URI: https://www.upwork.com/freelancers/~01f07c797570a44277
*/
include( plugin_dir_path( __FILE__ ).’slms-page.php’);
include( plugin_dir_path( __FILE__ ).’user-record-page.php’);
include( plugin_dir_path( __FILE__ ).’UserRecord.php’);
include( plugin_dir_path( __FILE__ ).’borrow-books-page.php’);
include( plugin_dir_path( __FILE__ ).’login-page.php’);
include( plugin_dir_path( __FILE__ ).’library-records-page.php’);
include( plugin_dir_path( __FILE__ ).’librarians-guide-page.php’);
define(‘SLMS_JSCSS’, plugin_dir_url(__FILE__).’includes/’);/** wp_redirect() does not work in some web server/host. Use ob_clean() and ob_start(). clean the output buffer and turn on output buffering
ob_start(); ob_clean();
*/
//add front end css
function slms_js_css(){
wp_enqueue_style(‘slms_enqueue’, SLMS_JSCSS.”front-style.css”);
wp_enqueue_script(‘slms_enqueue’);
}
add_action(‘wp_footer’,’slms_js_css’);/** Redirect WordPress Logout to Home Page */
add_action(‘wp_logout’,create_function(”,’wp_redirect(home_url());exit();’));
?>–
–
–
–
–
Here is the code of some of my php file(UserRecord.php) that is_user_logged_in() is not working./** public_html/wp-content/plugins/SLMS/UserRecord.php */
if ( !is_user_logged_in() ) {
wp_redirect( home_url() );
exit;
}
elseif(isset($_POST[‘saveUserBtn’]) and $_SERVER[‘REQUEST_METHOD’] == “POST”) {
insertRecord();/**
insertRecord();
echo “working” ;
*/}
elseif(isset($_POST[‘searchUNBtn’]) and $_SERVER[‘REQUEST_METHOD’] == “POST”) {
searchUNRecord();/**
searchUNRecord();
echo $_POST[‘searchUN’];
echo “Success”;*/
}elseif(isset($_POST[‘updateUserBtn’]) and $_SERVER[‘REQUEST_METHOD’] == “POST”) {
updateRecord();/**
updateRecord();
echo $_POST[‘ID’];
echo “Update Status”;*/
}- This topic was modified 7 years, 1 month ago by . Reason: easily read by others
- This topic was modified 7 years, 1 month ago by . Reason: easily read by others
- This topic was modified 7 years, 1 month ago by . Reason: easily read by others
- This topic was modified 7 years, 1 month ago by . Reason: easily read by others
The page I need help with: [log in to see the link]
- The topic ‘is_user_logged_in() Not Working on Some of My Plugin PHP File’ is closed to new replies.