Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have FB Auto Login plugin installed and i have wrote my own custom javascript to handle logins. Now my question is how do i override the jfb_output_facebook_init function with my own function which echos "Hello World" for example?

add_action('wp_footer', 'jfb_output_facebook_init');
function jfb_output_facebook_init()
{
global $jfb_name, $jfb_version, $opt_jfb_app_id, $opt_jfb_api_key, $opt_jfb_valid;
if( !get_option($opt_jfb_valid) ) return;

$channelURL = plugins_url(dirname(plugin_basename(__FILE__))) . "/facebook-platform/channel.html";
echo "\n<!-- $jfb_name Init v$jfb_version (NEW API) -->\n";
?>
<div id="fb-root"></div>
<script type="text/javascript">//<!--
  window.fbAsyncInit = function()
  {
    FB.init({
        appId: '<?php echo get_option($opt_jfb_app_id); ?>', status: true, cookie: true, xfbml: true, oauth:true, channelUrl: '<?php echo $channelURL; ?>' 
    });
    <?php do_action('wpfb_add_to_asyncinit'); ?>            
  };

  (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/<?php echo apply_filters('wpfb_output_facebook_locale', 'en_US'); ?>/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
//--></script>

}
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You can simply remove the old function using remove_action() hook, and add your own using add_action() hook.

Example -

remove_action('wp_footer', 'jfb_output_facebook_init');
add_action('wp_footer', 'your_function');
share|improve this answer
    
You sir, are a legend. Worked like a charm :) –  Loxzibit Aug 14 '12 at 14:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.