Re: BP-FBConnect Plugin
Not sure if it will help anyone but I’ll post it anyway.
I really wanted to launch my BP site with facebook integration AND Invite facebook Friends as well. And given that Andy said he will probably not be working on the BP Facebook Connect pluggin, well.. I made a rough workaround that did the job.
Hope it helps.
Requirements:
– You need to have BP-Facebook Connect installed.
– You need to have Exec-PHP plugin installed.
– You need to have Exclude Pages plugin installed (optional)
Step 1:
==================================
First, I made a new file called invitefriends.php. I put it the root directory of BP.. but you can place it anywhere you want and take care of the paths. This is the code (not sure if it will get throught the parsing functions of this forum… my apologies in advance if it doesn’t):
<?php
$root = dirname(__FILE__); // repeat dirname( as many times as folders levels you save this file… For instance: if you save it in wp-content, it should be dirname(dirname(__FILE__));
if (file_exists($root.’/wp-load.php’)) {
// WP 2.6
require_once($root.’/wp-load.php’);
} else {
// Before 2.6
require_once($root.’/wp-config.php’);
}
if (function_exists(‘fbc_facebook_client’)) {
// if the current user is a facebook user, show his/her friends…
$fbuid = fbc_facebook_client()->get_loggedin_user();
if ($fbuid) { ?>
<fb:serverfbml style=”width: 100%;”>
<script type=”text/fbml”>
<fb:fbml>
<fb:request-form
action=”<?php echo get_option(‘siteurl’); ?>”
method=”GET”
invite=”true”
type=”<?php echo get_option(‘blogname’); ?>”
content=”<?php echo get_option(‘blogname’).” : “.get_option(‘blogdescription’); ?>
<fb:req-choice url='<?php echo get_option(‘siteurl’); ?>’
label='<?php _e(‘Become a member!’, ‘mt_trans_domain’) ?>’ />”>
<fb:multi-friend-selector
showborder=”false”
actiontext=”<?php _e(‘Select the friends you want to invite.’, ‘mt_trans_domain’) ?>”>
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
<?php } else {
// If s/he is not a facebook user, tell him/her s/he has to be one in order to invite friends.
echo __( ‘Tienes que haber ingresado como un usuario Facebook para poder invitar amigos.’, ‘mt_trans_domain’ );
$user = wp_get_current_user();
if (!$user->ID) {
// if s/he is not a facebook neighter a site member yet… show the Facebook login button.
echo ‘
<fb:login-button size=”large” background=”dark” length=”long”></fb:login-button>’;
}
}
}
?>
==================================
Step 2:
– Create a new page, named it whatever you want (I name it Invite Facebook Friends, in spanish).
– Exclude this page from the front-page (using the Exclude-Page plugin)
The code of my page looks like this:
<?php
if (function_exists(‘fbc_facebook_client’)) {
// if the current user is a facebook user, load invitefriends.php into an IFRAME.
$fbuid = fbc_facebook_client()->get_loggedin_user();
if ($fbuid) { ?>
<iframe width=”100%” height=”700″ frameborder=”no” src=”invitefriends.php”></iframe>
<?php } else {
// If s/he is not a facebook user, tell s/him he has to be in order to invite friends.
echo ‘<p>Tienes que haber ingresado como un usuario Facebook para poder invitar amigos.’;
$user = wp_get_current_user();
if (!$user->ID) {
// If s/he is not a facebook nor a member… show her/him the facebook button.
echo ‘
<fb:login-button size=”large” background=”dark” length=”long”></fb:login-button>’;
}
echo ‘</p>’;
}
}
?>
==================================
As you can it is a extermelly rough approach… but I’m not a WordPress developer nor a WPMU one… nor a BP one… I’m not familiar with the plugin framework of WordPress so I tried to do my best.
I hope it helps.