how to check whether the user is admin?
#1
hi,
i wrote plugin, and i won't to inform the user how something happens, saying that I mean an event (call the script php )
how to send pm to user with sender='mybb_info' and title='xyz' and content='xyz2' and user who i send its "xy". ??? how can i do these?
i fix that


and second: how to check whether the user is admin?
Reply
#2
if($mybb->usergroup['cancp'])

This will check if they have ACP access, which will work for all admins.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#3
sorry, i mean my script for pm is work, but in a separate file works, but as it tries to add it to the main jumping bugs

Fatal error: Call to a member function simple_select() on a non-object in /home/ptmclan/public_html/inc/functions.php on line 4534

my pm code
?><?php
//Configuration Section...
$fromid = 324; // Set the ID of the user the message should be sent from
$PMsubject = "Użytkownik wyzwał Cię na bitwę."; //Subject of the PM
$PMmessage = "Cześć, wyzywam Cię na bitwę pt.\"\". Wygra ten kto zdobędzie więcej głosów. Czas trwania bitwy to x dni, masz 2dni na zaakceptowanie bitwy.";
//Set to the message you want to be sent in the pm

$toid=2;


$pm2 = array(
"subject" => $PMsubject,
"message" => $PMmessage,
"icon" => "-1",
"toid" => Array($toid),
"fromid" => $fromid,
"do" => '',
"pmid" => ''
);
$pm2['options'] = array(
"signature" => "0",
"disablesmilies" => "0",
"savecopy" => "0",
"readreceipt" => "0"
);

$pmhandler2->set_data($pm2);

if(!$pmhandler2->validate_pm())
{
}
//else
//{
$pminfo2 = $pmhandler2->insert_pm();
// }

unset($pm2);
unset($pmhandler2);
unset($pminfo2);


?><?
Reply
#4
You can use the function is_super_admin()
if(is_super_admin($uid))
{

}

Regarding to your error: make sure the $db object is globalized otherwise it will not be available in the function:
function myplugin_hook()
{
    global $db;
    $query = $db->simple_select("table","*","where clause");
    //...
}
Reply
#5
i have included, how to check ?
define("IN_MYBB", 1);
require_once "../global.php";
require_once MYBB_ROOT."inc/datahandlers/pm.php";
global $db, $mybb, $lang;
Reply
#6
(2011-01-03, 08:03 PM)Aries-Belgium Wrote: You can use the function is_super_admin()
if(is_super_admin($uid))
{

}

Apart from the fact that checks if they're a super admin, not a normal admin...
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#7
thanks, i have that, and i need script for pm.
my modyfication stops because i need sending pm. maybe i give code of my script ?




<?
define("IN_MYBB", 1);
require_once "./global.php";
global $db, $mybb, $lang;
if($mybb->user['uid'])
{
$sql = mysql_connect ("localhost","-------","-----")
or die ("Nie można się połączyć z bazą danych");
$db= mysql_select_db("--------", $sql)
or die ("Nie można wybrać bazy danych");
mysql_query('SET CHARACTER SET latin2');

echo "<head><!-- start: headerinclude -->"  ;
echo $headerinclude;

echo "<link rel='stylesheet' href='css/lightbox.css' type='text/css' media='screen' />  ";
echo "<script src='js/prototype.js' type='text/javascript'></script>        ";
echo "<script src='js/scriptaculous.js?load=effects,builder' type='text/javascript'></script> ";
echo "<script src='js/lightbox.js' type='text/javascript'></script>                ";
?>

<?

echo "</head>";

echo $header;

$hojo='username';

mysql_query(" my query");
echo "<center><big><font color='white'>Pojedynek został dodany pomyślnie czekaj na akceptacje przeciwnika w ciągu 48h</font></big></center>";
echo "<br><br><center> <a href='http://nfsworld.pl/akceptuj.php'>Powróć</a> </center>";

$z12 = mysql_query("SELECT * FROM `mybb_users` WHERE `mybb_users`.`username`='".$hojo."' LIMIT 1");
while($row5=mysql_fetch_array($z12))
{
$toid=$row5['uid'];
}
///////////////////////////////////////////////////////////////////
///////////////////////here i need pm with toid = array($toid);
//////////////////////////////////////////////////////////////////////  




?>
Reply
#8
If you can post your entire code, it would be more helpful as it seems you're incorrectly using some functions somewhere (possibly to do with getting thread link) which is causing the error.

If you do not want to post the code out here you can PM it.
Reply
#9
i send U pm
how to connect with other database ? in mybb $db. Best will be two simultaneously
Reply
#10
Mybb has no functionality to do that. You will have to connect using normal PHP Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)