Skip Navigation

[Resolved] Registration form w/ ONE generic field from POST

This thread is resolved. Here is a description of the problem and solution.

Problem:
Registration form w/ ONE generic field from POST

Solution:
It needs custom shortcode to build such solution.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/registration-form-w-one-generic-field-from-post/#post-1100254

Relevant Documentation:

This support ticket is created 5 years, 7 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Tagged: 

This topic contains 24 replies, has 2 voices.

Last updated by dmitryK-2 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1099312
tssupport-ticket-screen1.png
tssupport-ticket-screen2.png

I am trying to:
Hello dear support

Can you please state the right direction of making the realization of such an idea on pages of my dev site - hidden link (please confirm the exception of https... I'll fix it later))

I have News (like standard WP Posts, respective taxonomy category ID = 4) and CPT Events (respective taxonomy category id = 5) posts on it. Also I have tags taxonomy to classify the "organizer" of Event (ID's = 11 or 12).

On every page I need to insert PostForm (id992) "Online Registration". I need to prefill "Type of registration" field in this PostForm according to the following logic:

If Taxonomy category ID = 4 and Taxonomy category ID = 11 then I need to assign respective value e.g. '7' from 'sht-cf-type' field from original post (see screen 1)
If Taxonomy category ID = 5 and Taxonomy category ID = 12 then I need to assign respective value e.g. '3' from 'sht-cf-type' field from original post ...

and so on...

the list of values can be seen on screen 2.

<b>Please notify what is the best way of doing this?</b>

Target filed in PostFrom here:

[cred_field field='tscf-topic-mirror' value='' urlparam='' class='form-control' output='bootstrap']

Link to a page where the issue can be seen:
hidden link

#1099327

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I would like to know from where the taxonomy/category ID we can get?

Do you mean Post is assigned with such category and if post have been assigned with the combination of such category you want to prefill the specific ID from field 'sht-cf-type'?

#1099511

Hi Minesh

Yes, we have post with ID. = 373
It is assigned with taxonomies Category (ID=4) "News" and Tag (ID=11) "PSN"
Everything is quite standard

#1099530

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - could you please share access details so I can review your current setup that will help me to guide you in right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#1099550

Ok' I'll return in couple hours.

#1099558

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok fine - thank you.

I have set the next reply to private which means only you and I have access to it.

#1099631

Dear Minesh, is there recommended free tool (plugin) for multisite backup?

#1099691

Dear Minesh,
user been created.
Can you please switch to private message mode, so can I send information for you.

#1100238

Hello

#1100239

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - I have set the next reply to private which means only you and I have access to it.

#1100254

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you need a custom shortcode to check such combination of your category and tag.

For example - I've added following custom shortcode to your current theme's functions.php file, as you can see I've added couple of combination for which you shared the information. Feel free to customize it as per your need and add more combinations.:

function func_topic_mirror_id($atts){
	
	global $post;
	
	$tag_id = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); 
	$cat_id =  wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
	
	if($cat_id[0]==4 and $tag_id[0] ==11){
		return 7;
	}else if($cat_id[0]==5 and $tag_id[0] ==12){
		return 3;
	}
}
add_shortcode( 'topic_mirror_id', 'func_topic_mirror_id');

And I called the shortcode with your form field as given under:

 [cred_field field='tscf-topic-mirror' value='[topic_mirror_id]' urlparam='' class='form-control' output='bootstrap']

I see its returning correct value. Could you please confirm.

#1100262

Great!
I need some time for testing & return in 30 mins!

#1100282
tssupport-ticket-screen_3.png

Dear Minesh,
See on screen 2 attached to original post I had Toolset Custom Field [sht-cf-type]. Array of 1...n values with text descriptions. How can I also include it as 3rd parameter (sorry I 'm very weak in wp - coding)... can you please also help to add line in input parameters to extend my "derivation" logic.

' $sht_id = [which is equal to custom field [sht-cf-type] which I will assign to every post / page manually (see screen3) '
#1100287

P.s. It would be great to return TEXT values of [sht-cf-type] and put it in target field [cred_field field='tscf-topic-mirror' value='[topic_mirror_id]' urlparam='' class='form-control' output='bootstrap']

Thanks!

#1100491

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I've adjusted the code to display the TEXT values as given under:

function func_topic_mirror_id($atts){
	
	global $post;
	
	$tag_id = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); 
	$cat_id =  wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
	
	$options = get_option('wpcf-fields');
	$field_opt = $options['sht-cf-type']['data']['options'];
	
	$all_opt = array();
	foreach($field_opt as $k=>$v):
			$all_opt[$v['value']] = $v['title']; 	
	endforeach;
	
	if($cat_id[0]==4 and $tag_id[0] ==11){
		return $all_opt[7];
	}else if($cat_id[0]==5 and $tag_id[0] ==12){
		return $all_opt[3];
	}
}
add_shortcode( 'topic_mirror_id', 'func_topic_mirror_id');

Could you please check and confirm.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.