A A A
Forum Scope


Match



Forum Options



Min search length: 3 characters / Max search length: 84 characters
Forum Login
Lost password?
coding-topic
spa_get_usergroups_all();
Avatar
Stan Dahl

75 Posts
(Offline)
1
Oct 12, 2015 - 10:58 am
Print

Hi,

I want to use this function and I need to want what it returns.

spa_get_usergroups_all();

Is it an array? or multi-dimensional array?

Also, to call this from a 3rd party plugin’s admin panel in the WordPress admin, do I need to instantiate anything or refer to any global objects?

Thanks for your help!

Avatar
Mr Papa
Simi Valley, CA

19448 Posts
(Offline)
2
Oct 12, 2015 - 9:20 pm
Print

before calling the function, you might need to add:

sp_forum_api_support();

which will make sure forum api is fully loaded…

the function will return a php object… the members are the columns of the sfusergroups table in the db…

Avatar
Stan Dahl

75 Posts
(Offline)
3
Oct 14, 2015 - 5:11 pm
Print

HI Mr Papa – thank you for your help.

One last part I’m stuck with, if spa_get_usergroups_all() returns an object, is it of a particular class?

What I am expecting is some kind of list of all of the usergroups in the table.

so if I have:

$usergrps = spa_get_usergroups_all();

I can’t do:

$usergrps->usergroup_name;

because I need to iterate the rows of the table some how.

I’m sure I’m just not seeing the obvious with this, but any light you can shed on this would be greatly appreciated.

Thanks!

Avatar
Yellow Swordfish
Glinton, England

16436 Posts
(Offline)
4
Oct 14, 2015 - 5:25 pm
Print

You must extract the data in the

$usergrps->usergroup_name

form. It returns a class of the WP database OBJECT type. As, by default and if no user group ID is passed, it returns all user groups in the table – then you will need to iterate through them using a foreach loop.

So – something along the lines of:

$userGroups = spa_get_usergroups_all();
if($usergGroups) {
    foreach($userGroups as $group) {
        $group_name = $group->usergroup_name;
        // etc...
    }
}

is what you need…

andy-signature.png
YELLOW
SWORDFISH
Avatar
Stan Dahl

75 Posts
(Offline)
5
Oct 15, 2015 - 5:58 pm
Print

Hi Guys,

The following code is failing on the red function call

if ( function_exists ( ‘sp_forum_api_support’ ) ) {
   sp_forum_api_support();
   $swl_ugroups = spa_get_usergroups_all();

   …
}

Not sure how to debug this.

Does sp_forum_api_support() have any return values?

Avatar
Yellow Swordfish
Glinton, England

16436 Posts
(Offline)
6
Oct 16, 2015 - 4:00 am
Print

I can see there may be one or two function sequencing issues. Instead of making that call why not just use the code it contains which is – quite simply:

$swl_ugroups = return spdb_table(SFUSERGROUPS);
andy-signature.png
YELLOW
SWORDFISH
Avatar
Stan Dahl

75 Posts
(Offline)
7
Oct 16, 2015 - 9:46 am
Print

is “SFUSERGROUPS” a constant defined somewhere?

as it is written: $swl_ugroups = return spdb_table(SFUSERGROUPS);

doesn’t work either.

Is there something I’m missing with this entire setup?

Right now I have the Simple Press plugin installed. Is anything else needed for this to work?

I really don’t want to get to the point of writing a direct database call to the table myself

Avatar
Stan Dahl

75 Posts
(Offline)
8
Oct 16, 2015 - 10:01 am
Print

ok, made a bit of progress on this:

$swl_ugroups = spdb_table(SFUSERGROUPS);

this is actually giving me an array.

Avatar
Yellow Swordfish
Glinton, England

16436 Posts
(Offline)
9
Oct 16, 2015 - 10:44 am
Print

Sounds good. The main problem is one of scope. Any decent plugin will try and only load the components that are absolutely necessary on page loads where the plugin is not the actual focus. We actually take some pride in this respect and this function you were chasing (and I know we suggested it!) is not really a part of our API that is easier to expose.

Let us know how it goes…

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: America/New_York
All RSSShow Stats
Administrators: Blues Dancer, Simple Press, SP Community Support, Marcus (Simple:Press)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 630
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Newest Members:
Lorena Affleck
samantardh
PatrickAlawl
Hannelore Gaither
Margarito Nowacki
Elwood Mcclendon
samantaerx
Larue Cordeaux
Jerrold Stockman
Forum Stats:
Groups: 7
Forums: 17
Topics: 10071
Posts: 79393

 

Member Stats:
Guest Posters: 608
Members: 16976
Moderators: 0
Admins: 4

Most Users Ever Online
1170
Currently Online
Guest(s)
1
Currently Browsing this Page

1 Guest(s)