Not Solved Create a $Variable for the PlugIn Verified_User
#1
Not Solved
MyBB version: 1.8.27

Hello MyBB PHP Pros,

I have the PlugIn Verify Users in use.

Now I want to add in the ./inc/functions_online.php the variable:
if($user['verified'] == 1) {
statement
}
use.

How and where in the ./online.php or ./inc/functions_online.php must the variable
if($user['verified']
be defined to be available?

Alternatively:
Since the variable
if($user['verified']
is to be used in further PHP files, the question arises whether this could be defined vllt. even in e.g. the ./global.php?

Thanks in advance for tips and hints.
[Translated with www.DeepL.com/Translator (free version)Translated with www.DeepL.com/Translator (free version)]
Reply
#2
Not Solved
Really bad idea to add something in core files.

The better way is to create a plugin with a hook on global_intermediate (or global_start) to alter the way your forum work:
$plugins->add_hook('global_intermediate', 'ext_verify_user');
function ext_verify_user() {
   global $db, $mybb, $templates, $templatelist, $lang, $current_page, $user; // add useful variables
   if (!$db->field_exists('verified', 'users')) {
      return true;
   }
   if ($user['verified']==1) {
      // do what you want
   }
}
Tchat en français
Do not ask me help through PM or Discord

Reply
#3
Not Solved
First of all, thanks for your commitment to help me. The suggestion it about a PlugIn is certainly the better approach.

I have created and activated a PlugIn as follows:
$plugins->add_hook('global_start', 'ext_verify_user');
function ext_verify_user() {
   global $db, $mybb, $templates, $templatelist, $lang, $current_page, $user, $user_verified; // add useful variables
   if (!$db->field_exists('verified', 'users')) {
       return true;
    }
   if ($user['verified'] == 1) {
     $user_verified = 'verified';
   } else {
     $user_verified = 'not verified';
   }
}
However, when I include the defined variable $user_verified in the e.g. template online_row after {$online_name} with {$user_verified}, I get nothing displayed.
(The same will be at all Templates e.g. forumbit_depth2_forum_lastpost after {$lastpost_profilelink})

What am I doing wrong?
Reply
#4
Not Solved
Is your plugin working ?
Did you try adding a die('I\'m in'); after the global line to check the function is well called ?
Tchat en français
Do not ask me help through PM or Discord

Reply
#5
Not Solved
I pasted after global die('I\'m in MyBB'); and it shows up in the browser.
If I comment out the line again, the $variable is not displayed as before.

Start Test-Note:
If i write:
if (!$db->field_exists('verified', 'users')) {
   echo '<span style="font-size: 48px; color: #00f;">True</span><br />';
  return true;
} else {
  echo '<span style="font-size: 48px; color: #f00;">False</span><br />';
}
it will display me at the top of the Template False
Remove the exclamation mark it will display me at the top of the Template True

if i write:
if ($user['verified'] == 1) {
   echo '<span style="font-size: 48px; color: #00f;">Verifiied</span>';
} else {
   echo '<span style="font-size: 48px; color: #f00;">Not-Verified</span>';
}
it will display me at the top of the Template Not-Verified
But no matter what I define, the variables are not available.
End Test-Note:
Reply
#6
Not Solved
I think you have a wrong idea on what you need, because you need to use right hooks and vars to add the right values on the fly and do not add unnecessary queries, so in the current way as i can say you have not the right values to add the right desired results, because i think you have not the right values to get the entries you need and at some point you need to add those variants for the system should know where and what to add.
The only infinite thing is the universe and human stupidity, but the universe is not for sure

Plugins 1.6.x

Plugins 1.8.x

Reply
#7
Not Solved
Thanks for the feedback. I can understand your execution and it is understandable for me.

As a newbie, I am still dependent on the professionals to help me. More than to describe my problem, I can unfortunately not. As you can easily see from my postings, I am of course also thinking about it. This although I am only admin (no programmer) of a forum and just looking for a solution to my concern.

Think the solution can then certainly use other MyBB users.

Translated with www.DeepL.com/Translator (free version)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)