Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Capture data in admin area WordPress

  • REFUNDED

I'm trying to setup a page in admin area to capture some values and output the results on several pages and sidebar. [see attached image similar to my expectation]

It is a WP multisite install.

I've looked into meta boxes and custom fields, those are fine on pages and posts. as it is a multisite install, I can't determine the post id to call the field. [ that is my understanding].

how can I achieve this.

in admin area
page: Obituary Notice
field group 1: Name, date of birth, date of death, description, photo, place of birth, town, country.
field group 2(contact info): Name, Country, Tel [repeatable)
field group 3(cremation info): Date, Time, Venue, Post code

Please note: in field group 2 Tel field is repeatable, if they want to add more numbers, also the whole field group 2 is repeatable if they want to add another person.

in front end,
I like to use do_shortcode
or any of the following plugins
http://www.deluxeblogtips.com/meta-box-script-for-wordpress
http://www.farinspace.com/wpalchemy-metabox/
http://codecanyon.net/item/easy-custom-content-types-for-wordpress/234182

thanks in advance.

sri

Answers (2)

2011-10-19

Luis Abarca answers:

For the screen, you can use custom post type with a metabox.

To show in all sites the same info you can use a shared table to save the details, the blog and post ID, using the "save_post" hook.

So you can make a custom query to that table to get all records.


$wpdb->query('SELECT blogid, id, name, etc FROM mytable');


So you can swith to that blog and get the info from the post ID,


switch_to_blog( $blogid );

get_post( $postid );



sri rahulan comments:

Hi Luis,
let me make it clear,
each obituary gets it own site [subdomain]
each subdomain sites may have 4-5 pages, with in those 4-5 pages I want to call the field values entered in admin area.

workflow is,
when a new user signup, he will get a subdomain site, where he/she can post the obituary notice of their relatives. when they log in to the site, they will be presented with the obituary notice page in admin area. I want to call the mentioned fields in condolence page and other pages with in their site.

functions.php is much appreciated. [I'm not a tech saavy]
using any metabox/custom fields plugins mentioned on the initial post.

thanks

sri

2011-10-19

Sébastien | French WordpressDesigner answers:

i don't understand...

you speak about a page "Obituary Notice" and your image is an option page (transport option)

what do you want to do exactly ? and what's your problem ?


sri rahulan comments:

Hi Sébastien,
transport option image is just a reference from other site. just to show the visual functionality.

problem detailed on Luis reply.

thanks

sri


Sébastien | French WordpressDesigner comments:

arf !
you want create a meatbox with fields, simply
and need to display the value of each field in front
that's it ?


sri rahulan comments:

yes, that's right.


Sébastien | French WordpressDesigner comments:

ok ! i write the code !
just a moment !


Sébastien | French WordpressDesigner comments:

the metabow must be in a page ? in a post ? in custom post type (wich name in this case) ?


Sébastien | French WordpressDesigner comments:

i can create the code or you can use a very good solution : magic fields
very, very good solution
http://magicfields.org/

and i can help you to understand how use this plugin


Sébastien | French WordpressDesigner comments:

that's the code for the first group with two fields : name and firstname


add_action("admin_init", "admin_init");
add_action('save_post', 'save_meta');

function admin_init(){
add_meta_box("obituary-meta-group1", "obituary notice group1", "obituary_group1_options", "post", "advanced", "low");//replace post by page or by the name of the custom post type where yiu want your metabox
}

function obituary_group1_options(){
global $post;
$custom = get_post_custom($post->ID);
$obituary_lastname = $custom["obituary_lastname"][0];
$obituary_firstname = $custom["obituary_firstname"][0];
?>



<label><strong>Name </strong><br><input style="text-transform:uppercase" size="0" name="obituary_lastname" id="obituary_lastname" maxlength="255" type="text" class="large-text" value="<?=$obituary_lastname ?>"></label><br><br>
<label><strong>Firstname </strong><br><input style="text-transform:capitalize" size="0" name="obituary_firstname" id="obituary_firstname" maxlength="255" type="text" class="large-text" value="<?=$obituary_firstname ?>"></label><br><br>

<?php
}


function save_meta(){
global $post;

$obituary_lastname = $custom["obituary_lastname"][0];
$obituary_firstname = $custom["obituary_firstname"][0];


update_post_meta($post->ID, "obituary_lastname", $_POST["obituary_lastname"]);
update_post_meta($post->ID, "obituary_firstname", $_POST["obituary_firstname"]);
}


Sébastien | French WordpressDesigner comments:

if you want to display the name and the firstname in the front, use this code (for example in the single.php) :



$name= get_post_meta($post->ID,"obituary_lastname",TRUE";
if($name) echo "Name : " . $name;

$firstname= get_post_meta($post->ID,"obituary_firstname",TRUE";
if($name) echo "<br>Firstname : " . $firstname;


sri rahulan comments:

pls. find attached image

will you able to use one of the meta-fields plugin mentioned in the initial post, it will be easy for me to add more fields if needed in later stage.

will try your code and let you know.

thanks

-sri