Setting add listing TITLE from custom input fields

Hello! I hope someone can help me out with this...

I am creating a custom add listing input page and I will not use any predefined fields except one or two.

One I want to use is the TITLE, but I want it to be set from three custom fields entered from the user front-end interface.

So, instead of the user entering his own listing title, I would like to create it from three custom fields he has filled in.

The user fills in these from the front_ui :
Custom input fields : Country, Theme, Leader Name

Their codes being :

To illustrate the general idea in a basic code example:

$Title = [ct_Continent_selectbox_37b7] + [ct_Event_Titl_text_522d] + " with " + [ct_Name_of_Re_text_4503]

And the result to save to the title of the listing would look like this for example :

Jamaica Yoga Retreat with John Smith

Should I use this one :
$listing_data['post_title'] = ?

Would in be done in place of this piece of code in
page_update_listing.php ?

<?php if(post_type_supports('directory_listing','title') ): ?>
<div class="editfield">
<label for="title"><?php _e( 'Title', $this->text_domain ); ?></label>
<input class="required" type="text" id="title" name="listing_data[post_title]" value="<?php echo ( isset( $listing_data['post_title'] ) ) ? esc_attr($listing_data['post_title']) : ''; ?>" />
<p class="description"><?php _e( 'Enter title here.', $this->text_domain ); ?></p>

Any help provided would be very much appreciated, thanks!

  • Jeff

    Hi thanks two the both of you guys for the quick reply! :slight_smile:

    Indeed I want to go into the PHP code to combine them:
    It is ok to combine them after the submit is pressed.
    (the title does not have to be shown dynamically as they type in the fields)

    When back to edit screen:
    I do not have to "uncombine" them if the user goes back to the edit screen (because the fields are still apart so if he changes one of them the title will be updated after he submits with the code above)

    My issue is how to code that, ie:

    $listing_data['post_title'] = do_shortcode('[ct_id="ct_Leader1_we_text_e91d" property="value"]

    Would this pass on the value of the custom field to the title ?
    Thanks !

  • Arnold

    Think were you're at. Your on a form that just got loaded from the current data in the database and is now in your browser. You only have the HTML and javascript available at the browser. You can't use PHP on the template after it's loaded and before it's submitted.

    When you submit it, it's only going to send the data in the post body which is the name-value pairs.


    That gets sent back to the server and on the server side you have to combine them in PHP update_listing() which is where the values get put into the listing. Here's where you can use PHP to combine them a stuff them in the listing.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.