Simple Machines Community Forum

Customizing SMF => Bridges and Integrations => Topic started by: Jim R on July 02, 2009, 08:05:54 AM

Title: SMF and WordPress, a simple request... vbg
Post by: Jim R on July 02, 2009, 08:05:54 AM
Lots of materials found in search, but there are no real answers for bridging WordPress 2.8 and SMF 2.0+.  Using SMF log in/log out via SSI, whatever, I want it so when a user is logged into my SMF, they are also logged in and recognized in my WP with their SMF ID.

I don't know enough to get started or which hook to look at.  I don't know how to apply the hooks.  Right now I have my own PHP page, which utilizes SSI, but I'm wanting to use WP now, keeping SMF with its membergroups, paypal integration, etc.


Title: Re: SMF and WordPress, a simple request... vbg
Post by: KensonPlays on July 03, 2009, 06:51:05 PM
I'm having same issue, and I want to do this too...
Title: Re: SMF and WordPress, a simple request... vbg
Post by: Aleksi "Lex" Kilpinen on July 09, 2009, 05:59:40 AM
Hi Jim R, any updates on this? Have you found anything to do what you are after? :)
Title: Re: SMF and WordPress, a simple request... vbg
Post by: Jim R on July 15, 2009, 11:00:58 PM
I have not found a complete solution.  I'm not entirely sure I've figured out the issue of WordPress even acknowledging I'm logged into SMF via SSI.  However, worse are the errors I get in dealing with arrays. 

Quote
Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/jwrbloom/public_html/wp/wp-content/plugins/php_execution/includes/class.php_execution.php(270) : eval()'d code on line 6

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/jwrbloom/public_html/wp/wp-content/plugins/php_execution/includes/class.php_execution.php(270) : eval()'d code on line 6

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/jwrbloom/public_html/wp/wp-content/plugins/php_execution/includes/class.php_execution.php(270) : eval()'d code on line 6

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/jwrbloom/public_html/wp/wp-content/plugins/php_execution/includes/class.php_execution.php(270) : eval()'d code on line 6


Here is the code in question:


<?php
 $allowed_groups 
= array(12914);
$can_see FALSE;
foreach (
$allowed_groups as $allowed)
{
if (in_array($allowed$user_info['groups']))
{
$can_see TRUE;
break;
}
}

//If allowed to see...show this.
if ($can_see)
{
//Just stay right here and do nothing.

}

elseif (
$can_see == FALSE && $context['user']['is_logged'])
{


//If you want to redirect the user to another place you can use the redirectexit() function.
echo 'Registered but not subscribed.';
}
else
{
//Just redirect since they are just a guest.

echo 'Not registered.';

    

}
?>

Title: Re: SMF and WordPress, a simple request... vbg
Post by: H on July 31, 2009, 08:48:04 AM
Do you still require help with this?
Is $user_info['groups'] definitely populated with the group information? Perhaps it needs to be global'ed
Title: Re: SMF and WordPress, a simple request... vbg
Post by: Jim R on July 31, 2009, 04:36:08 PM
Quote from: H on July 31, 2009, 08:48:04 AM
Do you still require help with this?
Is $user_info['groups'] definitely populated with the group information? Perhaps it needs to be global'ed

I still do need help with this.  I'm wondering if it's an array issue, since having three Membergroups in the array produces three errors, while four Membergroups produces four. 
Title: Re: SMF and WordPress, a simple request... vbg
Post by: H on July 31, 2009, 04:59:58 PM
Which array do you mean? If there are four groups in $allowed_groups then the for loop would be executed four times which is why four errors would appear
Title: Re: SMF and WordPress, a simple request... vbg
Post by: Jim R on July 31, 2009, 06:55:15 PM
Quote from: H on July 31, 2009, 04:59:58 PM
Which array do you mean? If there are four groups in $allowed_groups then the for loop would be executed four times which is why four errors would appear

I figured that is why I think it's an issue with arrays.
Title: Re: SMF and WordPress, a simple request... vbg
Post by: H on July 31, 2009, 06:58:14 PM
Did you check the contents of $user_info['groups'] to check it is holding the correct groups? :)
Title: Re: SMF and WordPress, a simple request... vbg
Post by: Jim R on July 31, 2009, 07:33:27 PM
It's the same code I'm using elsewhere on normal PHP pages.
Title: Re: SMF and WordPress, a simple request... vbg
Post by: H on July 31, 2009, 07:39:14 PM
I'm guessing your other PHP pages aren't wrapped in wordpress in the same way though? The error implies that it can only be coming from one of two variables. If you don't check them and atleast eliminate them as the source of the problem it makes it very difficult for us to help you.
Title: Re: SMF and WordPress, a simple request... vbg
Post by: Jim R on July 31, 2009, 08:18:59 PM
I guess I don't know enough of how to test them.  I just know it's code that works elsewhere, but you're right, those aren't pages within WordPress.
Title: Re: SMF and WordPress, a simple request... vbg
Post by: H on August 01, 2009, 06:20:25 AM
print_r($user_info['groups']);

That code will print the entire array. Should be fine just to put it before the for() line