- <?php
- /* INCLUDING FILES FROM WORDPRESS. */
- /* START */
- require_once ('wp-config.php');
- require_once( 'wp-includes/registration.php');
- require_once( 'wp-includes/user.php');
- /* END */
- /* API CALL FROM BIGADDA TO GET USER DETAILS */
- /* START OF CALL */
- $apiurl = "http://s.api.bigadda.com/ws/custom/profile/_user/";
- $useridprofilecall ="http://s.api.bigadda.com/ws/custom/profile/_profile/";
- /* END OF CALL */
- /* MYSQL CONNECTION FOR DATABASE */
- $conn = mysql_pconnect(DB_HOST, DB_USER, DB_PASSWORD) or die ('Error connecting to mu wordpress');
- mysql_query("USE adda_production",$conn);
- $sqlselectuniqueblogusers = "SELECT * FROM clone_users" ;
- $addauseridresult = mysql_query($sqlselectuniqueblogusers,$conn);
- $num_rows = mysql_num_rows($addauseridresult);
- echo "<br>NUMBER OF RECORDS IN BLOGS TABLE = ".$num_rows;
- /* LOOPING ALL UNIQUE USERS FROM BLOGS TABLE */
- while($row=mysql_fetch_array($addauseridresult))
- {
- mysql_query("USE adda_production",$conn);
- $user_loginid=$row['id']; /* USERID FROM BLOGS TABLE */
- echo "<br>user_loginid = ".$user_loginid;
- /* EXTRACTING DETAILS OF USERS THROUGH API CALL */
- /* END OF CALL*/
- /* CHECK IF API CALL RETURNS ERROR */
- if(strstr($result,"Error:"))
- {
- echo $user_loginid ;
- echo "<br>error no user found so moving on with other users </br>" ;
- }
- else
- {
- /* UNCOMMENT THIS BELOW CODE TO GET DATA FROM API CALL*/
- // $json1 = json_decode($result,true);
- // $addausername = $json1[0]['profile_id'];
- $addausername = $row['username'];
- echo $addausername ;
- echo "<br>";
- $email = $row['email'];
- $password = $row['password'];
- echo "<br>user_loginid = ".$user_loginid;
- echo "<br>addausername = ".$addausername;
- /* END OF USER DETAILS FROM USERS TABLE IN ADDA_PRODUCTION*/
- /* SHIFT OF DATABASE FROM ADDA_PRODUCTION TO WORDPRESS */
- mysql_query("USE wordpress",$conn);
- /* CHECK IF USER IS ALREADY HAS WORDPRESS ACCOUNT */
- $sql_user_mu = mysql_query("select * from wp_users where user_login='$addausername'");
- $num_rec = mysql_num_rows($sql_user_mu);
- echo "<br>num_rec = ".$num_rec;
- if($num_rec == 0 )
- {
- /* BIGADDA USER DOESNT HAVE ACCOUNT ON WORDPRESS */
- /* DEFINING VARIABLES TO CREATE USER ON WORDPRESS */
- echo $addausername;
- $user_login = $addausername ;
- $test_login =str_replace(".","dot",$user_login);
- $test_login =strtolower($test_login);
- $domain =$current_site->domain;
- $path='/'.$test_login.'/';
- $title =$user_login;
- $user =$user_login;
- $user_email =$email;
- $registered='NOW()';
- $activation_key=$user_login."key";
- $meta='a:2:{s:7:"lang_id";i:1;s:6:"public";i:1;}';
- /* END OF DEFINING VARIABLES*/
- /* CHECK IF USER IS IN WORDPRESS IF NOT THEN ADD DETAILS IN WP_SIGNUP TABLE */
- $sql_insert_check=mysql_query("select * from wp_signups where user_login='$user_login'",$conn);
- $num_insert=mysql_num_rows($sql_insert_check);
- echo "<br>num_insert = ".$num_insert;
- if($num_insert==0)
- {
- /* INSERTING USER IN WP_SIGNUP TABLE IN WORDPRESS */
- echo "<br>CREATEBLOG FOR USING WPMU_SIGNUP_BLOG FUNCTION FOR = ".$user_loginid;
- wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta='' ) ;
- /* CHECK FOR USER DETAILS IN WP_SIGNUPS TABLE FOR ACTIVATING ACCOUNT */
- $sql_activate=mysql_query("select * from wp_signups where user_login='$user_login' and active='0'",$conn);
- $num_activate=mysql_num_rows($sql_activate);
- echo "<br>num_activate = ".$num_activate;
- if($num_activate==1)
- {
- /* START OF ACTIVATING ACCOUNT FOR NEWLY CREATED USER*/
- $key_row=mysql_fetch_array($sql_activate);
- $key=$key_row['activation_key'];
- /* WORDPRESS FUNCTION TO ACTIVATE ACCOUNT */
- echo "<br>ACTIVATE USER ACCOUNT FOR = ".$user_loginid;
- wpmu_activate_signup($key);
- $sql_password=mysql_query("select * from wp_users where user_login='$user_login'",$conn);
- $num_password=mysql_num_rows($sql_password);
- $key_password=mysql_fetch_array($sql_password);
- $id=$key_password['ID'];
- $new_password = $password; //MD5 PASSWORD FROM API CALL OR FROM DATABASE
- /* WORDPRESS FUNCTION TO CHANGE PASSWORD */
- echo "<br>CHANGE PASSWORD FOR = ".$user_loginid;
- wp_set_password( $new_password, $id);
- /* END OF ACTIVATING ACCOUNT FOR NEWLY CREATED USER*/
- /* CREATE BLOG POST FOR NEWLY CREATED USER FROM ADDA_PRODUCTION ON WORDPRESS */
- /* SWIFTING DATABASE TO ADDA_PRODUCTION */
- // mysql_query("USE adda_production",$conn);
- echo "<br>FUNCTION CALL FOR CREATING BLOG= ".$user_loginid;
- // create_blog_user($user_loginid,$addausername,$conn,$domain,$path);
- /* END OF CREATING BLOG POST FOR NEWLY CREATED USER*/
- }
- else
- {
- /* BIGADDA USER HAS ACCOUNT ON WORDPRESS */
- // mysql_query("USE adda_production",$conn);
- echo "<br>FUNCTION CALL FOR CREATING BLOG IF USER ALREADY HAS WORDPRESS ACCOUNT= ".$user_loginid;
- //create_blog_user($user_loginid,$addausername,$conn,$domain,$path);
- } /* END OF IF*/
- } /* END OF IF*/
- }
- }/* END OF WHILE LOOP FROM BLOGS TABLE */
- }
- ?>
Undefined
By: Guest | Date: Aug 3 2011 14:12 | Format: None | Expires: never | Size: 5.76 KB | Hits: 1222
Latest pastes
1 days ago
3 days ago
3 days ago
4 days ago
5 days ago