bp_core_signup_user hook not working (PHP, BuddyPress, Wordpress, & Parse.com) -
i have been trying hook wordpress registration action can store new user's account info on parse.com user database. however, since using buddypress, wp hook user_register
not seem work.
after doing research online, seems supposed use bp hook bp_core_signup_user
, not seem working, , info online on how should implemented years old , may outdated. problematically, buddypress not have codex @ all, kind of stuck. i've been @ hours, cannot figure out.
this function created in attempt hook registration process:
<?php // saves newly registered bp user account parse db. add_action('bp_core_signup_user', 'savenewparseuser', 10, 5); function savenewparseuser($userid, $userlogin, $userpass, $useremail, $usermeta) { //commit new user data http post request parse. $url = 'https://api.parse.com/1/users'; $postdata = array( "wpuserid" => $userid, "username" => $userlogin, "password" => $userpass, "email" => $useremail, "fullname" => $usermeta[display_name], "firstname" => $usermeta[first_name], "lastname" => $usermeta[last_name] ); $appid = "a5ttlvg52jktc************************"; $restapikey = "qc86ja8dy1fpcb**************************"; $options = array(); $options[] = "content-type: application/json"; $options[] = "x-parse-application-id: $appid"; $options[] = "x-parse-rest-api-key: $restapikey"; $options[] = "x-parse-revocable-session: 1"; //open connection $ch = curl_init($url); //sets number of post vars & post data curl_setopt_array($ch, array( curlopt_post => true, curlopt_postfields => json_encode($postdata), curlopt_httpheader => $options, curlopt_returntransfer => true )); //execute post $result = curl_exec($ch); $resultarray = json_decode($result, true); //error check if (curl_errno($ch)) { echo "error code " . curl_errno() . ": " . curl_error($ch); } //retrieve , place parse user session token & id wp db user account. add_user_meta($userid, 'parsesessiontoken', $resultarray[sessiontoken]); add_user_meta($userid, 'parseobjid', $resultarray[objectid]); curl_close($ch); }
what doing wrong? not being hooked , run meant to?
i know not work because check parse user db after registering account , new row not created, , meta info put wp account not show there @ all.
interestingly, did work when hooked wp's user_register
(with appropriate parameter , postdata
array setup) when included exit;
call @ end of function, prevented registration process going through buddypress' , activation procedure, , instead went straight registering through wordpress directly. left web page displaying output response http request - json response body expected parse, know did in fact work. why working when avoiding buddypress? buddypress seems causing problem here. (if see code had done differently this, can post it.)
thank assistance.
i figured out wrong, , feel complete idiot because should have been obvious.
there nothing wrong function - did not realize custom plugin contained in disabled! apparently happened when renamed php file, deleted 1 on server, , put new 1 in, before question became issue.
i learned lesson. , know changing plugin's files deactivate plugin whole.
as such, hook user_registration
still works fine, , not necessary go through bp_core_signup_user
hook, have reverted former. future reference wanting know, final function used:
<?php // saves newly registered wp user account parse db. add_action('user_register', 'savenewparseuser'); function savenewparseuser($newuserid) { //retrieve new user object wp's db. $newuser = get_userdata($newuserid); //commit new user data http post request parse. $url = 'https://api.parse.com/1/users'; $postdata = array( "wpuserid" => $newuserid, "username" => $newuser->user_login, "password" => $newuser->user_pass, "email" => $newuser->user_email, "fullname" => $newuser->display_name, "firstname" => $newuser->first_name, "lastname" => $newuser->last_name ); $appid = "a5ttlvg52jktcbc*******************"; $restapikey = "qc86ja8dy1f************************"; $options = array(); $options[] = "content-type: application/json"; $options[] = "x-parse-application-id: $appid"; $options[] = "x-parse-rest-api-key: $restapikey"; $options[] = "x-parse-revocable-session: 1"; //open connection $ch = curl_init($url); //sets number of post vars & post data curl_setopt_array($ch, array( curlopt_post => true, curlopt_postfields => json_encode($postdata), curlopt_httpheader => $options, curlopt_returntransfer => true )); //execute post $result = curl_exec($ch); $resultarray = json_decode($result, true); //error check if (curl_errno($ch)) { echo "error code " . curl_errno() . ": " . curl_error($ch); } //retrieve , place parse user session token & id wp db user account. add_user_meta($newuserid, 'parsesessiontoken', $resultarray[sessiontoken]); add_user_meta($newuserid, 'parseobjid', $resultarray[objectid]); curl_close($ch); }
Comments
Post a Comment