Recent Topics

1 Jan 01, 2009 00:29    

My b2evolution Version: 2.x

Hello.

How to check_perms to be sure user is a member of the Admin Group?

Thanks in advance.

2 Jan 01, 2009 01:14

global $current_User;
if( is_object($current_User) && $current_User->group_ID == 1 )
{
    do smth
}

3 Jan 01, 2009 01:35

Thanks for your reply, sam2kb.

I have:

global $current_User;
if( is_object($current_User) && $current_User->group_ID == 1 )
{
$allow_cross_posting = 3;
}
else
{
$allow_cross_posting = 1;
}

while logged in as 'admin' user. The 'else' condition is being the one it defaults to.

Thanks.

4 Jan 02, 2009 21:45

Well, I'm not sure but I've tried [everything] I can think of and it seems that the user variables are not available in this file - only those files it calls 'below' this top level. :(

Even with the global statement, $current_User, $Blog, $Session objects are NULL.

If someone else knows how to to get user info to this cross posting routine, please let me know.

Thanks in advance.

6 Jan 03, 2009 07:38

Thanks for your reply, sam2kb.

I don't have that file. Is it something I create? What is the background on its purpose - is it to override routines?

Thanks.

7 Jan 03, 2009 10:55

Use the plugin system, it's what it's there for ;)

function AdminDisplayEditorButton()
{
	global $allow_cross_posting, $current_User;
	switch( $current_User->group_ID )
	{
		case 1 :
			$allow_cross_posting = 3;
			break;

		default :
			$allow_cross_posting = 2;
			break;
	}
}

¥

8 Jan 03, 2009 11:02

Thanks for your reply, ¥åßßå.

I guess I'm unfamiliar with

Use the Plugin System.

Is the code you posted already located in a file or must it be added - if so, where?

I take it the location you're speaking of is not where sam2kb was talking about (conf/hacks.php which I don't have anyway).

Thanks in advance.

9 Jan 03, 2009 11:05

The code needs to go in a plugin which you need to create, take a look at the skeleton && test plugins in /plugins/

¥

10 Jan 03, 2009 11:10

Ohh... that's what you meant.

I did create a file called hacks.php since I didn't see one and could find any info in the manual nor forum about it. I then put the code as mentioned by sam2kb and it worked, too.

Now though, I'm still confused as to when to use that hacks.php file and what it's best used for and when versus using the plugin system.

Thanks.

11 Jan 03, 2009 11:12

You should use hacks.php for anything that can't be done by a plugin .... which is pretty rare.

¥

12 Jan 03, 2009 11:15

Thanks ¥åßßå.

I'll give the plugin route a-go, too.

13 Jan 03, 2009 20:35

You should use hacks.php for anything that can't be done by a plugin .... which is pretty rare.

Or when you don't want to waste the time creating a plugin ;)

14 Jan 03, 2009 20:37

heh, and then there's the times when it's quicker than hacking the core :D

.... but any other time, it should be a plugin :D

¥


Form is loading...