Plugin Directory

Changeset 460801


Ignore:
Timestamp:
11/09/2011 01:57:44 AM (14 years ago)
Author:
Messenlehner
Message:

BuddyPress Integration

Location:
wp-google-plus-connect/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-google-plus-connect/trunk/readme.txt

    r460383 r460801  
    11=== WP Google Plus Connect ===
    22Contributors: Messenlehner
    3 Tags: google+, google plus, google, plugin, login, admin, bridge, api
     3Tags: google+, google plus, google, plugin, login, admin, bridge, api, buddypress, registration
    44Requires at least: 3.0
    55Tested up to: 3.1
    6 Stable tag: 1.0
     6Stable tag: 1.0.1
    77License: GPLv2 or later
    88
    9 WP Google+ Connect allows your users to register and/or login via their Google+ account.
     9WordPress Google Plus Connect allows your WordPress/BuddyPress users to register and/or login via their Google+ account.
    1010
    1111== Description ==
    1212
    13 Allow your WordPress website users the ability to register and/or log in via their Google+ account utilizing the Google+ API. Set up a Google Plus Application and store the API credentials in the WordPress backend, when a user clicks on the "Login with Google+" button that gets added to the WP log in screen or anywhere via a short code and authenticates their Google Plus account a WordPress account will be created with their G+ information and they will automatically be logged in. Any existing WordPress users can also log in via Google+ and link their two accounts.
     13Allow your website members the ability to register and/or log in via their Google+ account utilizing the Google+ API. Set up a Google Plus Application and store the API credentials in the WordPress backend, when a user clicks on the "Login with Google+" button that gets added to the WP log in screen or anywhere via a short code and authenticates their Google Plus account a WordPress account will be created with their G+ information and they will automatically be logged in. Any existing WordPress or BuddyPress users can also log in via Google+ and link their two accounts.
     14
    1415
    1516== Installation ==
    1617
    1718Upload the wp-google-plus-connect plugin to your website, Activate it, then head to the "G+ Connect" link added to the settings menu.
     19
     20== Changelog ==
     21
     22= 1.0 =
     23* Plugin Launch
     24
     25= 1.0.1 =
     26* BuddyPress Compatible
  • wp-google-plus-connect/trunk/wp-google-plus-connect.php

    r460379 r460801  
    33Plugin Name: WP Google+ Connect
    44Plugin URI: http://webdevstudios.com/plugin/wp-google-plus-connect/
    5 Description: Register and/or login WordPress users via their Google+ Account utilizing the Google+ API
     5Description: Register and/or login WordPress/BuddyPress users via their Google+ Account utilizing the Google+ API.
    66Author: Brian Messenlehner of WebDevStudios.com
    77Author URI: http://webdevstudios.com
     
    99*/
    1010
     11//check for buddypress
     12add_action( 'bp_include', 'wds_google_connect_buddypress' );
     13function wds_google_connect_buddypress() {
     14    require( dirname( __FILE__ ) . '/buddypress.php' );
     15}
     16
     17//Google+ Auth and Button
    1118add_action('init', 'wds_google_connect_button');
    1219function wds_google_connect_button($button=false){
     
    6572        }
    6673        $gplus_displayName=$me['displayName'];
     74        $gplus_photo=$me['image']['url'];
    6775        if($gplus_id){
    6876          if($user_ID!=0){//if already logged into wp account but want to link with g+
     
    7684            if(!$user_id){
    7785              $new_user=true;
    78               $user_name=sanitize_user( $gplus_displayName );
     86              $user_name=$gplus_displayName;
     87              $arr_user_name=explode(" ",$user_name);
     88              $user_name=$arr_user_name[0];//user first name
     89              $user_name=sanitize_user( $user_name );
    7990              $user_name=str_replace(array(" ","."),"",$user_name);
    8091              $user = username_exists( $user_name );
     92              if ( $user ) { //try last name
     93                  $user_name=$arr_user_name[1];
     94                  $user_name=sanitize_user( $user_name );
     95                  $user_name=str_replace(array(" ","."),"",$user_name);
     96                  $user = username_exists( $user_name );
     97              }
     98              if ( $user ) { //try first & last name
     99                  $user_name=$gplus_displayName;
     100                  $user_name=sanitize_user( $user_name );
     101                  $user_name=str_replace(array(" ","."),"",$user_name);
     102                  $user = username_exists( $user_name );
     103              }
    81104              if ( $user ) { //if username happens to exsit tie a random 3 digit number to the end
     105                  $user_name=$arr_user_name[0];
     106                  $user_name=sanitize_user( $user_name );
     107                  $user_name=str_replace(array(" ","."),"",$user_name);
    82108                  $user_name=$user_name.rand(100, 999);
    83109                  $user = username_exists( $user_name );
     
    93119                        update_user_meta($user_id, 'nickname', $gplus_displayName);
    94120                        update_user_meta($user_id, 'display_name', $gplus_displayName);
     121                        //budypress functions
     122                        if(function_exists('wds_bp_check')){
     123                            wds_google_connect_bp_user($user_id,$gplus_displayName,$gplus_photo);//buddypress.php
     124                        }
    95125                    }
    96126                    update_user_meta($user_id, 'wds_google_connect_user_id', $gplus_id);
     
    117147    if ($button==true) {
    118148      if (!$client->getAccessToken()) {
    119           $state = mt_rand();
     149          if($_SESSION['state']){
     150            $state=$_SESSION['state'];
     151          }else{
     152            $state = mt_rand();
     153          }
    120154          $client->setState($state);
    121155          $_SESSION['state'] = $state;
     
    158192    register_setting( 'wds_google_connect_settings_group', 'wds_google_connect_redirect_url' );
    159193    register_setting( 'wds_google_connect_settings_group', 'wds_google_connect_developer_key' );
     194    //buddypress
     195    register_setting( 'wds_google_connect_settings_bp', 'wds_google_connect_bp_login' );
     196    register_setting( 'wds_google_connect_settings_bp', 'wds_google_connect_bp_profile' );
     197    register_setting( 'wds_google_connect_settings_bp', 'wds_google_connect_bp_registration' );
     198    register_setting( 'wds_google_connect_settings_bp', 'wds_google_connect_bp_required' );
     199    register_setting( 'wds_google_connect_settings_bp', 'wds_google_connect_bp_activity' );
    160200}
    161201
     
    177217        <div class="icon32" id="icon-options-general"><br /></div>
    178218        <h2>Google+ Connect Settings</h2>
    179         <ul>
    180         <li>Visit the <a rel="nofollow" target="_blank" href="https://code.google.com/apis/console/?api=plus">Google API Console</a> to generate your developer key, OAuth2 client id, OAuth2 client secret, and register your OAuth2 redirect uri. </li>
    181         <li>Click on "Services" in the left column and turn on "Google+ API".</li>
    182         <li>Click on "API Access" in the left column and click the button labeled "Create an OAuth2 client ID" </li>
    183         <li>Give your application a name and click "Next" </li>
    184         <li>Select "Web Application" as the "Application type" </li>
    185         <li>Click on (more options and enter <?php echo site_url();?> into each textarea box)</li>
    186         <li>Click "Create client ID" </li>
    187         <li>Fill in the fields below with the generated information</li>
    188         </ul>
    189         <form method="post" action="options.php">
    190             <table class="form-table">
    191             <?php settings_fields( 'wds_google_connect_settings_group' );?>
    192                 <tr valign="top">
    193                     <th scope="row">Product Name:</th>
    194                     <td><input type="text" name="wds_google_connect_app_name" value="<?php echo $wds_google_connect_app_name; ?>" size="75" /></td>
    195                 </tr>
    196                 <tr valign="top">
    197                     <th scope="row">Client ID:</th>
    198                     <td><input type="text" name="wds_google_connect_client_id" value="<?php echo $wds_google_connect_client_id; ?>" size="75" /></td>
    199                 </tr>
    200                 <tr valign="top">
    201                     <th scope="row">Client Secret:</th>
    202                     <td><input type="text" name="wds_google_connect_client_secret" value="<?php echo $wds_google_connect_client_secret; ?>" size="75" /></td>
    203                 </tr>
    204                 <tr valign="top">
    205                     <th scope="row">Redirect URI:</th>
    206                     <td><input type="text" name="wds_google_connect_redirect_url" value="<?php echo $wds_google_connect_redirect_url; ?>" size="75" /></td>
    207                 </tr>
    208                 <tr valign="top">
    209                     <th scope="row">API Key:</th>
    210                     <td><input type="text" name="wds_google_connect_developer_key" value="<?php echo $wds_google_connect_developer_key; ?>" size="75" /></td>
    211                 </tr>
    212             </table>
    213             <p class="submit">
    214             <input type="submit" class="button-primary" value="Save Settings" />
    215             </p>
    216         </form>
    217         <h2>Google+ Login Button</h2>
    218         <img title='Google+ Connect!' src='<?php echo plugins_url('gplus-button.png',__FILE__);?>'><br />
    219         <strong>Button Short Code:</strong> [gplus_button]<br />
    220         <strong>PHP Function:</strong> &lt;?php wp_gplus_login_button();?&gt;<br /><br />
    221 
     219        <br />
     220        <?php $view=$_GET['view'];
     221        if(function_exists('wds_bp_check') && 1==2){?>
     222            <a <?php if($view==""){echo "style='font-weight:bold;'";}?> href="<?php echo add_query_arg( array ( 'view' => '' ) );?>">API Configuration</a> |
     223            <a <?php if($view=="bp"){echo "style='font-weight:bold;'";}?> href="<?php echo add_query_arg( array ( 'view' => 'bp' ) );?>">BuddyPress Settings</a>
     224            <br /><br />
     225        <?php }
     226        if($view==""){?>
     227          <ul>
     228          <li>Visit the <a rel="nofollow" target="_blank" href="https://code.google.com/apis/console/?api=plus">Google API Console</a> to generate your developer key, OAuth2 client id, OAuth2 client secret, and register your OAuth2 redirect uri. </li>
     229          <li>Click on "Services" in the left column and turn on "Google+ API".</li>
     230          <li>Click on "API Access" in the left column and click the button labeled "Create an OAuth2 client ID" </li>
     231          <li>Give your application a name and click "Next" </li>
     232          <li>Select "Web Application" as the "Application type" </li>
     233          <li>Click on (more options and enter <?php echo site_url();?> into each textarea box)</li>
     234          <li>Click "Create client ID" </li>
     235          <li>Fill in the fields below with the generated information</li>
     236          </ul>
     237        <?php } ?>
     238          <form method="post" action="options.php">
     239              <table class="form-table">
     240              <?php if($view==""){?>
     241                  <?php settings_fields( 'wds_google_connect_settings_group' );?>
     242                  <tr valign="top">
     243                      <th>Product Name:</th>
     244                      <td><input type="text" name="wds_google_connect_app_name" value="<?php echo $wds_google_connect_app_name; ?>" size="75" /></td>
     245                  </tr>
     246                  <tr valign="top">
     247                      <th>Client ID:</th>
     248                      <td><input type="text" name="wds_google_connect_client_id" value="<?php echo $wds_google_connect_client_id; ?>" size="75" /></td>
     249                  </tr>
     250                  <tr valign="top">
     251                      <th>Client Secret:</th>
     252                      <td><input type="text" name="wds_google_connect_client_secret" value="<?php echo $wds_google_connect_client_secret; ?>" size="75" /></td>
     253                  </tr>
     254                  <tr valign="top">
     255                      <th>Redirect URI:</th>
     256                      <td><input type="text" name="wds_google_connect_redirect_url" value="<?php echo $wds_google_connect_redirect_url; ?>" size="75" /></td>
     257                  </tr>
     258                  <tr valign="top">
     259                      <th>API Key:</th>
     260                      <td><input type="text" name="wds_google_connect_developer_key" value="<?php echo $wds_google_connect_developer_key; ?>" size="75" /></td>
     261                  </tr>
     262              <?php }elseif($view=="bp"){
     263                  $wds_google_connect_bp_login=esc_attr(get_option('wds_google_connect_bp_login'));
     264                  if($wds_google_connect_bp_login){
     265                      $wds_google_connect_bp_login="checked";
     266                  }
     267                  $wds_google_connect_bp_profile=esc_attr(get_option('wds_google_connect_bp_profile'));
     268                  if($wds_google_connect_bp_profile){
     269                      $wds_google_connect_bp_profile="checked";
     270                  }
     271                  $wds_google_connect_bp_registration=esc_attr(get_option('wds_google_connect_bp_registration'));
     272                  if($wds_google_connect_bp_registration){
     273                      $wds_google_connect_bp_registration="checked";
     274                  }
     275                  $wds_google_connect_bp_required=esc_attr(get_option('wds_google_connect_bp_required'));
     276                  if($wds_google_connect_bp_required){
     277                      $wds_google_connect_bp_required="checked";
     278                  }
     279                  $wds_google_connect_bp_activity=esc_attr(get_option('wds_google_connect_bp_activity'));
     280                  if($wds_google_connect_bp_activity){
     281                      $wds_google_connect_bp_activity="checked";
     282                  }
     283                  settings_fields( 'wds_google_connect_settings_bp' );?>
     284                  <tr valign="top">
     285                      <td>
     286                      <input type="checkbox" name="wds_google_connect_bp_login" value="1" <?php echo $wds_google_connect_bp_login;?>  />
     287                      Add Google+ login button to BuddyPress sidebar login
     288                      </td>
     289                  </tr>
     290                  <tr valign="top">
     291                      <td>
     292                      <input type="checkbox" name="wds_google_connect_bp_profile" value="1" <?php echo $wds_google_connect_bp_profile;?>  />
     293                      Add Google+ login button to logged in members profile
     294                      </td>
     295                  </tr>
     296                  <tr valign="top">
     297                      <td>
     298                      <input type="checkbox" name="wds_google_connect_bp_registration" value="1" <?php echo $wds_google_connect_bp_registration;?>  />
     299                      Add Google+ login button to BuddyPress registration page
     300                      </td>
     301                  </tr>
     302                  <tr valign="top">
     303                      <td>
     304                      <input type="checkbox" name="wds_google_connect_bp_required" value="1" <?php echo $wds_google_connect_bp_required;?>  />
     305                      Require Google+ connected members to fill out required BuddyPress profile fields
     306                      </td>
     307                  </tr>
     308                  <tr valign="top">
     309                      <td>
     310                      <input type="checkbox" name="wds_google_connect_bp_activity" value="1" <?php echo $wds_google_connect_bp_activity;?>  />
     311                      Allow members to import their Google+ activity as BuddyPress activity
     312                      </td>
     313                  </tr>
     314              <?php } ?>
     315              </table>
     316              <p class="submit">
     317              <input type="submit" class="button-primary" value="Save Settings" />
     318              </p>
     319          </form>
     320          <h2>Google+ Login Button</h2>
     321          <img title='Google+ Connect!' src='<?php echo plugins_url('gplus-button.png',__FILE__);?>'><br />
     322          <strong>Button Short Code:</strong> [gplus_button]<br />
     323          <strong>PHP Function:</strong> &lt;?php wp_gplus_login_button();?&gt;<br /><br />
     324       
    222325        For support please visit the <a target="_blank" href="http://webdevstudios.com/support/forum/wp-google-plus-connect/">WP Google+ Connect Plugin Support Forum</a> | Version by <a target="_blank" href="http://webdevstudios.com">WebDevStudios.com</a><br />
    223326
Note: See TracChangeset for help on using the changeset viewer.