Exemplo n.º 1
0
function stc_login_check($user)
{
    if (is_a($user, 'WP_User')) {
        return $user;
    }
    // check if user is already logged in, skip
    $tw = stc_get_credentials();
    if ($tw) {
        global $wpdb;
        $twuid = $tw->screen_name;
        $user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'twuid' AND meta_value = '%s'", $twuid));
        if ($user_id) {
            $user = new WP_User($user_id);
        } else {
            do_action('stc_login_new_tw_user', $tw);
            // hook for creating new users if desired
            global $error;
            $error = '<strong>ERROR</strong>: Twitter user not recognized.';
        }
    }
    return $user;
}
Exemplo n.º 2
0
function stc_comm_fill_in_fields($comment_post_ID)
{
    if (is_user_logged_in()) {
        return;
    }
    // do nothing to WP users
    $tw = stc_get_credentials();
    if ($tw) {
        $_POST['author'] = $tw->name;
        $_POST['url'] = 'http://twitter.com/' . $tw->screen_name;
        // use an @twitter email address. This shows it's a twitter name, and email to it won't work.
        $_POST['email'] = $tw->screen_name . '@fake.twitter.com';
    }
}
Exemplo n.º 3
0
function stc_publish_preauth()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
    }
    $tw = stc_get_credentials(true);
    $options = get_option('stc_options');
    // save the special settings
    if ($tw->screen_name) {
        $options['autotweet_name'] = $tw->screen_name;
        $options['autotweet_token'] = $_SESSION['stc_acc_token'];
        $options['autotweet_secret'] = $_SESSION['stc_acc_secret'];
    }
    update_option('stc_options', $options);
}