Home Forums Plugin Support WP User Frontend Pro Need help with wp_postmeta fields!

This topic is: resolved

This topic contains 32 replies, has 5 voices, and was last updated by  lwrkrol 5 years, 9 months ago.

Viewing 15 posts - 1 through 15 (of 33 total)
  • Author
    Posts
  • #1977

    retroga_me
    Participant
    Post count: 29

    Hi there! I recently purchased a WordPress Theme that uses a custom taxonomy called “Items”, and I want to use WP User Frontend Pro to provide the frontend-editing for it.
    Now I do see several custom taxonomies showing up in the form editor, but there’s one field that I can’t get to work, and that’s the Google Map/Streetview field.

    When I check PHPmyAdmin, I find the following field: _ait-dir-item in wp_postmeta

    With the content: 

    a:19:{s:7:”address”;s:17:”Street”;s:11:”gpsLatitude”;s:17:”12.341251949999999″;s:12:”

    gpsLongitude”;s:17:”12.34779700000025″;s:18:”streetViewLatitude”;s:17:”22.46046022895586″;

    s:19:”streetViewLongitude”;s:17:”22.006520910937523″;s:17:”streetViewHeading”;

    s:1:”0″;s:15:”streetViewPitch”;s:1:”0″;s:14:”streetViewZoom”;s:1:”0″;s:9:”telephone”;s:0:””;

    s:5:”email”;s:17:”tester@retroga.me”;s:3:”web”;s:0:””;s:11:”hoursMonday”;s:0:””;s:12:”hoursTuesday”;s:0

    :””;s:14:”hoursWednesday”;s:0:””;s:13:”hoursThursday”;s:0:””;s:11:”hoursFriday”;s:0:””;s:13:”hoursSaturday

    “;s:0:””;s:11:”hoursSunday”;s:0:””;s:18:”alternativeContent”;s:4:”Test”;}

    I was wondering how I could access those variables, so that I can make this work with the theme.

    Thanks in advance!

    #1978

    Tareq Hasan
    Keymaster
    Post count: 2831

    The data you posted, is the post meta. From the theme (single.php), you can get the data by using: [php]
    $location = get_post_meta( $post->ID, ‘_ait-dir-item', true );
    [/php]

    Seems like it's an array, you can view the contents by print_r( $location );.

    I am not sure how is this related with your “Items” taxonomy and what's exactly wrong happening with the taxonomy?

    #1986

    retroga_me
    Participant
    Post count: 29

    Hi Tareq, thanks for the quick reply!
    First of all I've got to say that you've made quite an awesome plugin, so there's that :).
    I might have my WordPress lingo all messed up, so I'll try to explain it as good as I can.

    The theme I am currently using is called WP Directory, and it comes with a custom post type called “Item”, which supposedly is the ait-dir-item. The theme has some built-in Google Maps magic that allows you to show a map with a marker, or a streetview in your header.

    When creating a new Item, you can select several custom fields, amongst one is the Google Maps/Streetview field.

    I would like to have that entire form on the frontend so that people can add their own Items without having to go to the backend of WordPress. I've tried setting the meta keys to the ones shown in my previous post (like address etc.) but somehow I'm not writing the variable to the ait-dir-item array.

    I've set the custom post type in the plugin, so I would've thought it would write to the custom post meta keys too. Since it's an array, would I have to enter anything special in the meta key field?

    If you need any more information, let me know :).

    Cheers.

    #1989

    Tareq Hasan
    Keymaster
    Post count: 2831

    From the plugins built in Google Maps meta field, it's not possible to save the exact information in exact format as this theme saves. But in can be adapted I guess.

    The plugin comes with some actions/filters and with the help of these action/filters you can achieve those. You can use the plugins Google map for taking the data and manipulate it to save it in the themes meta format. Or you can display your themes Geo data meta box in the plugins form and bind to the plugins action hook and save them.

    If you are not a developer, I guess you need help from a developer to achieve this. Take a look in this developer docs and how I made Pronamic Google Maps plugin to work with my plugin.

    #2010

    retroga_me
    Participant
    Post count: 29

    Thanks, I'll give it a try! Not new to programming, but new to PHP so I consider this a good excersize :).

    #2124

    retroga_me
    Participant
    Post count: 29

    I just tried and tried again, but it's still not working.

    Tareq, I see for instance that the wpuf_form is also saved as a serialized array. Is there a way to have WP User Frontend Pro save its data in a serialized array somehow, just like wpuf_form?

    #2127

    Tareq Hasan
    Keymaster
    Post count: 2831

    The trick you need to use is, when you are submitting the form, all the submitted values can be found in $_POST variable. So binding a function to the action wpuf_add_post_after_insert, you've to create an array and save it to the _ait-dir-item meta key by update_post_meta( $post_id, '_ait-dir-item', $your_array );. That way, your array will be saved in serialized form just like the theme did.

    #2154

    retroga_me
    Participant
    Post count: 29

    Hi Tareq, thanks for the reply! What you're saying makes total sense, apart from the fact that I myself aren't capable of such PHP magic . I don't want to coerce you into spelling it out entirely for me (although it would be appreciated), but I guess I'll take a book on PHP and get myself accustomed with WordPress a bit more on the code level and leave the custom post item editing in the backend for now.

    Thanks for your help so far though, love the plugin and the level of support!

    #2307

    retroga_me
    Participant
    Post count: 29

    Well… so far nothing new… Although is there a way to add a complete metabox to the frontend in one go? All of the info seems to be saved in _ait-dir-item_metabox

    #2309

    Tareq Hasan
    Keymaster
    Post count: 2831

    Meta box is also a function, so it can be added directly by calling that function to the plugin hook.

    #2311

    retroga_me
    Participant
    Post count: 29
    This reply has been marked as private.
    #2337

    retroga_me
    Participant
    Post count: 29

    Ok… Here goes:

    I got this function:

    http://pastebin.com/3SurHf5z

    I pasted that in wpuf-functions.php, then the theme told me I could not redefine that function, so I deleted it from the theme's functions.php

    And it still doesn't work. Now to be fair, I think I'm hacking too much at it :P.

    #2358

    Tareq Hasan
    Keymaster
    Post count: 2831

    I think you are searching the wrong thing. Can you paste the function that displays the location meta box in the theme?

    #2362

    retroga_me
    Participant
    Post count: 29

    Hi Tareq!

    This might be it:

    http://pastebin.com/A1vrdzUz

    It's in functions-dir.php of the theme.

    Sorry for all the hassle. If I get it to work though, I'll do my best to promote the plugin with the theme users, since they're all hoping that I can get it to work with the theme :).

    Best regards,

    Vincent

    #2367

    Tareq Hasan
    Keymaster
    Post count: 2831

    You want to show the same meta box to the frontend, right? That's not the page I was looking for. Wrong file 😉

Viewing 15 posts - 1 through 15 (of 33 total)

The topic ‘Need help with wp_postmeta fields!’ is closed to new replies.