=')) { return; } } deactivate_plugins(basename(__FILE__)); // Deactivate ourself wp_die("The base AllPlayers.com plugin must be activated before this plugin will run."); } register_activation_hook(__FILE__, 'ap_login_activation_check'); // add the section on the user profile page add_action('profile_personal_options','ap_login_profile_page'); function ap_login_profile_page($profile) { $options = get_option('ap_options'); ?> ID, 'apuuid'); if (empty($apuuid)) { ?>

Connected to AllPlayers.com

ID, 'apuuid'); if ($apuuid == $_POST['apuuid']) { delete_usermeta($user->ID, 'apuuid'); } echo 1; exit(); } add_action('ap_login_connect','ap_login_connect'); function ap_login_connect() { if (!is_user_logged_in()) return; // this only works for logged in users $user = wp_get_current_user(); $ap = ap_get_credentials(); if ($ap) { // we have a user, update the user meta update_usermeta($user->ID, 'apuuid', $ap->uuid); } } add_action('login_form','ap_login_add_login_button'); function ap_login_add_login_button() { global $action; if ($action == 'login') echo '

'.ap_get_connect_button('login').'


'; } add_filter('authenticate','ap_login_check'); function ap_login_check($user) { if ( is_a($user, 'WP_User') ) { return $user; } // check if user is already logged in, skip $ap = ap_get_credentials(); if ($ap) { global $wpdb; $apuuid = $ap->uuid; $user_id = $wpdb->get_var( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'apuuid' AND meta_value = '%s'", $apuuid) ); if ($user_id) { $user = new WP_User($user_id); } else { do_action('ap_login_new_ap_user',$ap); // hook for creating new users if desired global $error; $error = 'ERROR: AllPlayers.com user not recognized.'; } } return $user; } add_action('wp_logout','ap_login_logout'); function ap_login_logout() { session_start(); session_unset(); session_destroy(); } // add the AllPlayers.com to the admin bar add_filter('admin_user_info_links','ap_login_admin_header'); function ap_login_admin_header($links) { $user = wp_get_current_user(); $apuuid = get_user_meta($user->ID, 'apuuid', true); if ($apuuid) $links[7]="AllPlayers.com"; return $links; }