My Child-theme funtions.php file and shortcode is [my-shortcode]
<?php
function wpb_postsbycategory() {
// the query
$the_query = new WP_Query( array( 'category_name' => 'yhteystiedot', 'posts_per_page' => 1, 'orderby' => 'post_date', 'order' => 'DESC' ) );
// The Loop
if ( $the_query->have_posts() ) {
$string .= '<div class="postsbycategory widget_recent_entries">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$string .= '<div>'.'' .get_the_content() .'</div>';
$string = apply_filters('the_content', $string);
$string = str_replace(']]>', ']]>', $string);
}
} else {
// no posts found
}
$string .= '</div>';
return $string;
/* Restore original Post Data
wp_reset_postdata();*/
}
// Add a shortcode
add_shortcode('my-shortcode', 'wpb_postsbycategory');
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
]]>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”;*/
}
Produces a fatal error in geolocation line:182 undefined function is_user_logged_in()
Currently tested and repeated in two instances – development environment
researched: Our reference
]]>
<p>
<?php
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
echo 'Welcome, visitor!';
}
?>
</p>
Which works as expected on all pages other than the events list page.
When the events list view as is set to List, is_user_logged_in() always returns false regardless of whether a user is logged in or not. However, if the events list view is set to Month or Day, is_user_logged_in() returns the expected value depending on the user’s logged in status.
Is this a bug or is there something I don’t understand about how the events list view is implemented?
]]>I’m working on multiplesite on wordpress based on sub domain basis. How can I disable the WP Super cache for all the subdomains.
My another question is “WP Super Cache cannot tell logged-in users properly” – means is_user_logged_in() seems to be not working if WPSC is enabled.
Need help urgently
]]>}
]]>I’m using Buddypress for my website. I have created a notice for my users and I’m using this code:
<?php if ( is_user_logged_in() ) {
echo '<span class="notice-user">
<div>
<p> You can send friend requests and Messages to this user</p>
</div>
<span>';
}
?>
While this is working absolutely fine for the visitors, This code also shows up the notice if the user visits his OWN profile.
So, If user XYZ visits ABC. This notice should be there but if user XYZ visits his own profile i.e. XYZ’s profile, this notice should not be there.
Any idea How can I do that?
Thanks in advance!
]]>I have found this weird issue. Im using this function to display a welcome message for logged in users. Everything works, logout, login, etc.
After login on My Account page the Top Bar is succesfully updated and the welcome message appears, but if I go to the front page the Welcome message is not appearing. It is displayed on every other page, shop, posts, categories, etc. Just not on the front page.
If I refresh the front page with CTRL+R the welcome message appears correctly.
I have disabled caching for front page too.
Also tried this code, to flush it on login:
add_action('wp_login', 'mj_flush_w3tc_cache');
function mj_flush_w3tc_cache()
{
if (function_exists('w3tc_pgcache_flush_post')) {
w3tc_pgcache_flush_post(233);
}
}
Thanks for the help
https://www.ads-software.com/plugins/w3-total-cache/
]]>if( isset($_COOKIE['wordpress_logged_in_'.COOKIEHASH]) ):
but the same happened; the cookie is there, the plugin is login the user in but something else is making this check fail. The weird thing is that this is only happening when login in through the plugin.
If I refresh the page, the function or the wordpress_logged_in isset comprobation works great.
Any ideas? I’m driving myself crazy…
Thanks!
https://www.ads-software.com/plugins/wp-facebook-login/
]]>