aryanduntley
Forum Replies Created
-
Forum: Plugins
In reply to: [Gravity Forms Mass Import] "Import Entries" no longer in menu listI don’t actively support this plugin (no new revisions or updates will be made), however I do still provide support through this depository. I am not sure what is causing the issue. It works fine for me and this is the only such complaint I’ve had of this nature. Please disable all plugins except for gravity forms and the mass importer and try again. Also, if you send me an email, I will send you a cleaner copy of gravity-forms-mass-import.php. When I look at this file, after subversion this file ends up looking terrible and I think it has something to do with the large strings, I don’t know. Anyway, I fixed it and updated and it still turns out screwed up after subversion. I don’t have the time to go through and work on this until it’s right and the code still seems to be working fine. It is the only alternative I can offer you at this point. [email protected]
Forum: Plugins
In reply to: [Gravity Forms Mass Import] "Import Entries" no longer in menu listYa, this works in all version of gravity forms and it’s pretty standard wordpress api to get the sub link. Try going to this link:
{yoursite.com}/wp-admin/admin.php?page=gf_import_entries
Also, if you have ftp access, go to your wp-config file and change the debug to true. Let me know what shows up.
Forum: Plugins
In reply to: [Gravity Forms Mass Import] "Import Entries" no longer in menu listUhm. Still seems to work for me. What version of gravity forms are you using?
There simply is no id relative to the post in question, being passed to the meta. I don’t understand why you want to pass the post id to meta when the post id is available in the same json group that the meta relative to that post is displayed. Still, if you must include the post id with the meta you could do something like this:
function manipulate_meta($_post, $post, $context){ $thispostID = $_post['ID']; $thispostMeta = $_post['post_meta']; foreach($_post['post_meta'] as $k => $v){ //work with each individual meta data } $_post['post_meta']['currpostID'] = $_post['ID']; return $_post; } add_filter('json_prepare_post', 'manipulate_meta');Once again, I don’t see why this is necessary. The post id is available in the json object being returned.
You cant use:
apply_filters( ‘json_prepare_post’, $_post, $post, $context );It is what you stated you tried when you created the support request, however you said you were trying to use a loop function to get the id and some arbitrary variable “$post_id”. You should be able to access the post id with either $_post[‘ID’] or $post[‘ID’] (either of the first two parameters being passed to the filter hook. So:
function manipulate_meta($_post, $post, $context){
$thispostID = $_post[‘ID’];
$thispostMeta = $_post[‘post_meta’];
/*
sort meta
do things with post id
access other $_post data
*/
return $_post;
}
add_filter(‘json_prepare_post’, ‘manipulate_meta’);Forum: Plugins
In reply to: [WP REST API (WP API)] Filter by meta key/valueYou have to hook into json-valid-vars
$valid_vars = apply_filters(‘json_query_vars’, $valid_vars);
so:
function addsomevars($filters){ $metaparts = array("meta_key", "meta_value", "meta_compare", "meta_query"); $filters = array_merge($filters, $metaparts); return $filters; } add_filter('json_query_vars', 'addsomvars');If you wanted to make sure “meta_query” worked right, you could use the additional filter here:
$query[ $var ] = apply_filters( 'json_query_var-' . $var, $filter[ $var ] );That could look something like this where you pass the meta_query value as serialized data (from maybe_serialize):
function custom-filtermetq($val){ return maybe_unserialize($val); } add_filter('json_query_var-meta_query', 'custom-filtermetq');the param might look something like this:
&filter[meta_query]=a%3A1%3A%7Bi%3A0%3Ba%3A3%3A%7Bs%3A3%3A%22key%22%3Bs%3A5%3A%22color%22%3Bs%3A5%3A%22value%22%3Bs%3A4%3A%22blue%22%3Bs%3A7%3A%22compare%22%3Bs%3A8%3A%22NOT+LIKE%22%3B%7D%7DThe above is urlencoded from : a:1:{i:0;a:3:{s:3:”key”;s:5:”color”;s:5:”value”;s:4:”blue”;s:7:”compare”;s:8:”NOT LIKE”;}}
NOTE: not tested, just wrote it. Play with these hooks and you’ll get the filtering you want. Remember to urlencode the data. It seems that maybe_unserialize decodes the url just fine, but you may want to check up on that.
Forum: Plugins
In reply to: [WP REST API (WP API)] Registration and ExamplesOk, for those of you who need registration, here is what I have come up with. Please note that the methods below that are empty and do nothing have arguments passed that may not work. The api only sends certain data to certain functions (and “_” data to all), so the $data param will only be available to some of the methods (the ones responsible for creation/editing). This extension creates a new user with the data passed to it (ext_pass, ext_login, ext_nicename, ext_email, ext_display_name, ext_nickname, ext_first_name, ext_last_name) and also will create additional user meta under the key (as an array) $data[‘ext_usermeta’].
/***********************
Place in your functions/plugin file
***********************/function user_mbpregistration($server) { global $registration_api; require_once('class-wp-json-registration.php'); $registration_api = new User_ExtendRegister($server); add_filter( 'json_endpoints', array($registration_api, 'registerRoutes') ); } add_action( 'wp_json_server_before_serve', 'user_mbpregistration' );/*************************
This class is in it’s own file. In this case ‘class-wp-json-registration.php as defined in the action above.
*************************/class User_ExtendRegister{ protected $server; public function __construct(WP_JSON_ResponseHandler $server) { $this->server = $server; } public function registerRoutes( $routes ) { $routes['/mbpusers'] = array( array( array( $this, 'mbpAllUsers'), WP_JSON_Server::READABLE ), array( array( $this, 'newMBPUser'), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ), ); $routes['/mbpusers/user/(?P<user>\d+)'] = array( array( array( $this, 'getMBPUser'), WP_JSON_Server::READABLE ), array( array( $this, 'editMBPUser'), WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON ), array( array( $this, 'deleteMBPUser'), WP_JSON_Server::DELETABLE ), ); return $routes; } public function mbpAllUsers($_headers, $data = ''){ //array (for Collections) or an object (for Entities). if(isset($_SERVER['PHP_AUTH_USER'])){ $rettr = "This will eventually display some useful information. Your credentials are USR: " . $_SERVER['PHP_AUTH_USER'] . " PASS: " . $_SERVER['PHP_AUTH_PW']; }else{$rettr = "You are not logged in. When you are logged in successfully, your credentials will be displayed here.";} return array('returnedData'=>$rettr); } public function newMBPUser($data, $_headers){ if(!current_user_can('create_users')){return new WP_Error( 'json_cannot_publish', __( 'Sorry, you are not allowed to create new users' ), array( 'status' => 403 ) );} unset( $data['ID'] ); $upass = empty($data['ext_pass'])?'':$data['ext_pass']; $ulogin = empty($data['ext_login'])?'':$data['ext_login']; $unice = empty($data['ext_nicename'])?$ulogin:$data['ext_nicename']; $ueml = empty($data['ext_email'])?'':$data['ext_email']; $udisplay = empty($data['ext_display_name'])?$ulogin:$data['ext_display_name']; $unick = empty($data['ext_nickname'])?$ulogin:$data['ext_nickname']; $ufirst = empty($data['ext_first_name'])?'':$data['ext_first_name']; $ulast = empty($data['ext_last_name'])?'':$data['ext_last_name']; if(!$upass){return new WP_Error('json_insert_error', __('Password not passed, required.'), array( 'status' => 500));} if(!$ulogin){return new WP_Error('json_insert_error', __('Username not passed, required.'), array( 'status' => 500));} if(!$ueml){return new WP_Error('json_insert_error', __('Email not passed, required.'), array( 'status' => 500));} $userdata = array( "user_pass" => $upass, "user_login" => $ulogin, "user_nicename" => $unice, "user_email" => $ueml, "display_name" => $udisplay, "nickname" => $unick, "first_name" => $ufirst, "last_name" => $ulast, "description" => '', "user_registered" => current_time('mysql', 1), "role" => 'subscriber' ); $newuID = wp_insert_user( $userdata ); if(is_wp_error( $newuID)){ return new WP_Error('json_insert_error', $newuID->get_error_message(), array( 'status' => 500)); } $umarray = $data['ext_usermeta']; foreach($umarray as $k => $v){ $td = empty($v)?'':$v; update_user_meta($newuID, $k, $td); } return apply_filters( 'json_register_newuser', array('userID'=> $newuID), $data); } public function getMBPUser($data, $_headers, $user){ //array (for Collections) or an object (for Entities). } public function editMBPUser($data, $_headers, $user){} public function deleteMBPUser($data, $_headers, $user){} }/********************************************/
The array to be passed will look something like this before being serialized:
$userparams = array( 'ext_pass' => 'fakerpasw', 'ext_login' => 'FAKERUNAME', //'ext_nicename' => '', 'ext_email' => '[email protected]', //'ext_display_name' => , //'ext_nickname' => , 'ext_first_name' => 'FAKEGUEY', 'ext_last_name' => 'FAKINGNAME', 'ext_usermeta' => array( 'address' => '123 fake st.', 'city' => 'KA', 'state' => 'US', 'postalcode' => '92109', 'mobilenum' => '123-456-7890', 'carrier' => 'npt', 'dob' => '1/2/13', 'sex' => 'male', 'wanttext' => 'no', 'colorwant' => 'pink' ) );Forum: Plugins
In reply to: [WP REST API (WP API)] Authentication hacksIt is possible authentication will not work for those running php as CGI/SuExec
I found a good resource that provides a fix for this (or a workaround anyway):
http://www.besthostratings.com/articles/http-auth-php-cgi.htmlIn order to implement this with the API, first adjust your .htaccess file by adding
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>then utilize the authentication filter to provide http authentication values (NOTE: This example is using base 64 decode which means that the authentication values were sent with base 64 encoding *base64_encode(“username:password”)*):
function fixTheCheckAuth(){
list($_SERVER[‘PHP_AUTH_USER’], $_SERVER[‘PHP_AUTH_PW’]) = explode(‘:’ , base64_decode(substr($_SERVER[‘HTTP_AUTHORIZATION’], 6)));}
add_filter(‘json_check_authentication’, ‘fixTheCheckAuth’);/8============================================8/
The above actually did not work for me. This did however, it is a method from a responder in the resource above (http://www.besthostratings.com/articles/http-auth-php-cgi.html)Sébastien Marinier Said,
May 07, 2009 @ 10:57With Apache 2.2 and PHP 5(cgi mode), i’ve used
SetEnvIfNoCase Authorization “Basic ([a-z0-9=]+)” REMOTE_AUTHORIZATION=$1
This gives me $_SERVER[“REDIRECT_REMOTE_AUTHORIZATION”] as a global var.
I don’t know if “REDIRECT_” prefix is due to my configuration/environment. You may try without it.After, you can use the following code, before user both PHP_AUTH_* vars in a traditionnal way:
if (isset($_SERVER[“REDIRECT_REMOTE_AUTHORIZATION”]) && $_SERVER[“REDIRECT_REMOTE_AUTHORIZATION”]!=”){
$d = base64_decode($_SERVER[“REDIRECT_REMOTE_AUTHORIZATION”]);
list($_SERVER[‘PHP_AUTH_USER’], $_SERVER[‘PHP_AUTH_PW’]) = explode(‘:’, $d); }I haven’t looked for the method that parses the routs into variables, but it’s very probably in the server class. You can go there and call the method if it’s public to get the rout id from the url, or you can use php to parse the url yourself and get the post id. The filter you’re using is not passed the post id, only the meta (and only those which are unprotected).
Forum: Plugins
In reply to: [WP REST API (WP API)] Registration and ExamplesOk, just went through the code. Post Meta is not yet available. Neither is registration. I’ll extend the api so I can use this now and make a new insert_post method that incorporates meta. It will just be an additional post parameter ‘post_meta” that accepts an array of key/value pairs. I may check to see if the keys exist already, but all of that will be accessible through a filter that passes the post ID after creation/editing of the post (I’m surprised you don’t already have that filter). I am also having to register a new endpoint for registration. Still need to work out how best to authorize. I’ll post code here as I build these things out for others to use if they are having similar needs.
Forum: Plugins
In reply to: [Gravity Forms Mass Import] Single quotes get \ before themYeah, it parsed out. It is the ASCII code for the apostrophe.
http://www.natural-innovations.com/wa/doc-charset.html
so & #39; (without the space) will parse out as an apostrophe.Forum: Plugins
In reply to: [Gravity Forms Mass Import] Single quotes get \ before themTake a look at your CSV file. The escaping may be occurring in the conversion to the csv. I don’t believe I added any escaping in my code anywhere. It’s been a while since I built this plugin so not really sure, I just doubt it. Another thing you could do is to do a search and replace for ‘ and replace them all with ' and in case that parses out it is ( & + # + 3 + 9 + ; ) Remove so #39; with an & in front of it.
Forum: Plugins
In reply to: [Gravity Forms Mass Import] date_created importFor those wishing to do something similar, this is a possible solution (though untested at this time):
Try putting this as a replacement for line 422 in parcecsv.php:
$daterow = $row[‘actualPostDate’];
if($daterow){$_created_date = gmdate(“Y-m-d H:i:s”, strtotime($daterow;));}else{$_created_date = utc_timestamp();}
$wpdb->query( $wpdb->prepare(“INSERT INTO $entry_tracking_table (id, form_id, date_created, ip, source_url, user_agent, currency, created_by, status) VALUES (%d,%d,{$_created_date},%s,%s,%s,%s,{$_created_by},%s)”,$_id, $_form_id, $_ip, $_source_url, $_user_agent, ‘USD’, ‘active’));For this to work you have to create a field called “actualPostDate”. You can make it a hidden field if you want.
Forum: Plugins
In reply to: [Gravity Forms Mass Import] Importing Lists with Multiple ColumnsYou have to look at the explanations after you choose a form. It explains how to work with fields that can take multiple values and has examples for the various fields that do have those.. Basically, all you have to do is provide a comma separated list inside of double quotes for that csv column.
Forum: Plugins
In reply to: [Gravity Forms Mass Import] date_created importThere are two ways to do this. The first option would be to adjust the code so that instead of using now(), it uses a form field (which seems to be what you are asking). That would require code adjustment and because it’s specific to you, I would not do this as an update.
The other option would be to create another gravity forms field in your form and populate it with the dates you have in your csv. This may not work exactly as you may need, but I am not sure the context in which you need these dates.
So, because I am not going to be making any updates to the plugin and this is a very custom order, we can discuss this off the forum [email protected].