IPB

Welcome Guest ( Log In | Register )

Movable Type

We're moving to movabletype.org!

At long last, we're moving to forums powered by, well, Movable Type itself. You'll want to bookmark http://forums.movabletype.org/ for future reference, and in the meantime you can view these old forums as a read-only archive of past posts. Thanks for being part of the community!

> Accessing Author_meta Using Php, Reading and writing serialized content with php
lzw8bk
post Mar 6 2008, 05:11 AM
Post #1





Group: Members
Posts: 12
Joined: 9-June 05
From: Leesburg, VA
Member No.: 31,629



Here's a challenge:

I have need to access the customfields values in the author record using php. I am on MT-4.1 with the professional pack.

I have read Arvind's tutorial to access plugindata_data using php (Arvind's example code) and tried to incorporate it for accessing mt-authors->author_meta->customfields.

It appears the serialization is a bit more complex but the basic logic should be the same. The blog_id in question is 7.

Here's my code adapted from Arvind's tutorial:

CODE
include('/home/theconsulting/www/www/cgi-bin/mt/php/mt.php');
$mt = new MT(7, '/home/theconsulting/www/www/cgi-bin/mt/mt-config.cgi');
$db =& $mt->db;
// author_meta where author_id = 'N'
// or where author_name = $username
$data = $db->get_var("select author_meta from mt_author where author_name = 'merv.forney@erols.com'", ARRAY_A);

// Everything stored in plugindata_data is serialized so to be usable,
// we must unserialize it
$data = $db->unserialize($data);
$geoLat = $data['geocode_latitude'];
$geoLong = $data['geocode_longitude'];


There are several custom fields in the author records and I want to get to the GeoCode fields for a Google Map application (both read and write).

It appears the db select is not returning a result. I do not get any php warnings or errors and not sure where to look for MT errors besides the Activity Log (no errors there either). I am absolutely sure the record exists with the author_name supplied in the select statement because it is me.

I'm hoping I have overlooked something simple or perhaps MT-4 has changed significantly since Arvind's example.

It would seem that I may not be the only one developing more advanced applications to read and write serialized data in MT records.

Any help you can provide (or point me in the right direction) would be appreciated.
Merv Forney

This post has been edited by lzw8bk: Mar 6 2008, 05:13 AM
Go to the top of the page
 
+Quote Post

Posts in this topic
- lzw8bk   Accessing Author_meta Using Php   Mar 6 2008, 05:11 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 11.25.09 - 05:25 AM