Skip Navigation

[Gelöst] Split: How to assign a specific handler to a dog for each event

This support ticket is created vor 5 Jahre, 1 Monat. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Waqar vor 5 Jahre, 1 Monat.

Assistiert von: Waqar.

Author
Artikel
#1227628

thnk you waqas that sorted it lovely , i have hot a bit of a road block here upon entering data , when i add a dog to the event results , i also have a handler for the dog , i can enter multiple handlers for each dog but cant seem to assign a specific handler to a dog for each event , it shows all handlers for the dog on each event , rather than just the handler for the dog at that one event. any thoughts?

#1227645

Waqar
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Karachi (GMT+05:00)

Hi Martin,

If your goal is to save a "Handler" info with an individual dog, with respect to an individual event, you can add a new select type field to your "Events Dogs" relationship.

Step 1 screenshot: versteckter Link
versteckter Link

Step 2 screenshot: versteckter Link
versteckter Link

You can name this new "Select" field as "Dog Handler for the Event" and you don't need to add any options, as they'll be included programmatically.
Step 3 screenshot: versteckter Link

Next, to generate a list of all handlers for this new field, you can add the following code, at the bottom of your active theme's "functions.php" file:


add_filter( 'wpt_field_options', 'populate_dog_handler_select', 10, 3);
function populate_dog_handler_select( $options, $title, $type ){
	switch( $title ){
		case 'Dog Handler for the Event':

			$options[] = array(
					'#value' => '',
					'#title' => '- Select -',
			);

			$args = array(
				'post_type'        => 'handler',
				'posts_per_page'   => -1,
				'post_status'      => 'publish'
			);

			$posts_array = get_posts( $args );
			foreach ($posts_array as $post) {
				$options[] = array(
					'#value' => $post->ID,
					'#title' => $post->post_title,
				);
			}

		break;
	}

	return $options;
}

Important note: Please make sure that the "Dog Handler for the Event" matches the title of this new field and the "handler" matches the slug of the "Handlers" post type.

As a result, when you'll be adding/connecting a dog with an event on the event's edit screen, you'll see this new field with a list of all available handlers to add to this entry.
Screenshot: versteckter Link

Note: this list will show all handlers and not the just the ones connected to the selected dog. To show only those handlers, which are connected to the selected dog, complex custom programming will be needed, which is beyond the scope of support that we can provide.

For more personalized assistance around custom code, you can always consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.