GoodLiving, Make Our Self An Agent

This time, i want to share something great for GoodLiving theme.

By default, i you check the demo or you already own this theme, you will find out that people who already submit their property listing forced to choose which property agent they want to set as the mediator to buy their property listing.

They don’t know how good is the property agent or what they can do with their property. So, what is the point here? It is like giving your property to someone you don’t know personally.

At this tutorial i want to share some modification to allow people who submit their own property at your site to set them self as the mediator, which means no third party to sell their property. All inquiries sent to them self.

To do this modification, you have to modify at least 3 files: theme-options.php, sidebar.php and theme-submit-property.php.

Step#1

At this first step, you have to prepare the post meta for your custom post type (property). To do this, you have to modify a file named theme-options.php (you can find out this file via FTP at directory: wp-content > themes > goodliving > includes).

Find out this code:

$colabs_metaboxes[] = array (  "name"  => $post_type."_citystate",
					            "std"  => "",
					            "label" => __("City and State","colabsthemes"),
					            "type" => "text",
					            "desc" => __("Enter the City and State in one line.  You can include the zip/postal code, but we think it looks better without.  This will <strong>NOT</strong> be used as search criteria. ","colabsthemes"));		

Once you find that code, put this code below just after that code:

$colabs_metaboxes[] = array (  "name"  => $post_type."_agent_choose",
					            "std"  => "false",
								"label" => __("Use an agent?","colabsthemes"),
					            "type" => "radio",
								"options" => array( 'true' => __("Yes, i will use an agent provided here","colabsthemes"),'false' => __("No, i'm the agent for my self","colabsthemes")),
					            "desc" => __("Use an agent?","colabsthemes"));

This option will make a post meta that will store the value of an option whether people who submit listing into your site want to use the provided third party agent or not.

First step already done. You can check into your dashboard and try to add a new property, a new post meta should be available there.

Step#2

At this step you have to modify a file named theme-submit-property.php (you can find out this file via FTP at directory: wp-content > themes > goodliving).

At this step we will displaying the option that used to choose the option whether people want to use the third party agent or not. Find out this code:

update_post_meta($post_id, "property_price", $_POST['property_price']); 
				update_post_meta($post_id, "property_beds", $_POST['property_beds']); 
				update_post_meta($post_id, "property_baths", $_POST['property_baths']); 
				update_post_meta($post_id, "property_address", $_POST['property_address']); 
				update_post_meta($post_id, "property_citystate", $_POST['property_citystate']); 
				update_post_meta($post_id, "property_size", $_POST['property_size']); 
				update_post_meta($post_id, "property_garage", $_POST['property_garage']);
				update_post_meta($post_id, "property_furnished", $_POST['property_furnished']); 
				update_post_meta($post_id, "property_mortgage", $_POST['property_mortgage']);
				update_post_meta($post_id, "property_agent", $_POST['property_agent']); 

Update that code become:

update_post_meta($post_id, "property_price", $_POST['property_price']); 
				update_post_meta($post_id, "property_beds", $_POST['property_beds']); 
				update_post_meta($post_id, "property_baths", $_POST['property_baths']); 
				update_post_meta($post_id, "property_address", $_POST['property_address']); 
				update_post_meta($post_id, "property_citystate", $_POST['property_citystate']); 
				update_post_meta($post_id, "property_size", $_POST['property_size']); 
				update_post_meta($post_id, "property_garage", $_POST['property_garage']);
				update_post_meta($post_id, "property_furnished", $_POST['property_furnished']); 
				update_post_meta($post_id, "property_mortgage", $_POST['property_mortgage']);
				update_post_meta($post_id, "property_agent", $_POST['property_agent']); 
				update_post_meta($post_id, "property_agent_choose", $_POST['property_agent_choose']); 

Then, find out this code:

array(
                'field_name' => 'property_location',
                'field_label' => __('Location', 'colabsthemes'),
                'field_values' => 'property_location',
                'field_type' => 'select-tax',
                'field_req' => '',
              ),

Put this code just after that code above:

array(
                'field_name' => 'property_agent_choose',
                'field_label' => __('Using an Agent?', 'colabsthemes'),
                'field_values' => array( 'true' => __("Yes, i will use an agent provided here","colabsthemes"),'false' => __("No, i'm the agent for my self","colabsthemes")),
                'field_type' => 'radio',
                'field_req' => true,
              ),

That is the option. Once you update the file, you can start checking your add new listing page and you will find a new option available to be used.

Step#3

At this last step, you have to modify a file named sidebar.php. At this file we will add some logic. The logic will check what option you choose for the agent, you will use the third party or not.

Open the file and find out this code:

<?php if(is_singular('property')){
		$id_property=$post->ID;
		$emailsent=get_permalink($id_property);
		$agent_id = get_post_meta($id_property, "property_agent", true);
		$current_user = wp_get_current_user();
		?>

Update that code become:

<?php if(is_singular('property')){
		$id_property=$post->ID;
		$emailsent=get_permalink($id_property);
		
		$self_agent= get_post_meta($id, 'property_agent_choose',true);
		
		if ($self_agent =='true') {
			$agent_id = 'self';
		} else {
			$agent_id = get_post_meta($id_property, "property_agent", true);
		}	
		$current_user = wp_get_current_user();
		?>

And you are done!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s