I used the following script, retrieve the user ID from user table on WordPress. This script is working local server, all other server. But this is not working in the Hostinger server.
Why this is not working in Hostinger?
Only this is print_r($query); but $userid=$query[0][ID]; ID not found
<?php
if (sanitize_text_field($_GET['ven_search_title']) && sanitize_text_field ($_GET['ven_search_title']))
{
$ven_search_title = sanitize_text_field($_GET['ven_search_title']);
}
global $wpdb;
$table = $wpdb->prefix . 'users';
$query = $wpdb->get_results("SELECT * FROM $table WHERE user_nicename LIKE '%".$ven_search_title."%'", ARRAY_A);
if($query){
echo "<pre>";
print_r ($query);
echo "</pre>";
$userid=$query[0][ID];
echo "<pre>";
print_r ($query[0][ID]);
echo "</pre>";
?>
<?php $user=get_userdata($userid)?>
<a href="<?php echo bloginfo('url').'/store/'.$user->user_nicename; ?>">
<div class="store-wrappers">
<div class="seller-avatar"><?php echo get_avatar($userid) ?></div>
<div class="storebody">
<div class="search_title"><span>Store Name:</span> <?php echo $user->user_nicename; ?> </div>
</div>
<div style="clear:both;"></div>
There are some mistakes in your code. For example
bloginfo('url')is already echoed by itself. Your code can be simplified a bit and secured.Try the following:
Tested, lightweight, more secure and work.