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 6 years, 2 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 6 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1100852

Dear Minesh, I've tested it - slight improvements needed. can you please take a look at my comments in code below:

function func_topic_mirror_id($atts){
	
	global $post;
	
	//added line WE GET POST ID EXAMPLE 333
	//$post_id = get_post( $post->ID, array( 'fields' => 'ids' )  )
	$tag_id = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); 
	$cat_id =  wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
	
	//HERE WE HAVE TO UNDERSTAND WHAT VALUE OF sht-cf-type IS IN POST ID 333
	$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;
	
	//HERE WE HAVE TO COPY TEXT OF sht-cf-type FROM POST ID 333 TO TARGET FIELD tscf-topic-mirror
	if($cat_id[0]==4 and $tag_id[0]==11){
		return $all_opt[5];
	}
		else if($cat_id[0]==5 and $tag_id[0] ==12){
			return $all_opt[3];
		}
}
add_shortcode( 'topic_mirror_id', 'func_topic_mirror_id');
#1101550

Hi Minesh, can you please help

#1101576

Minesh
Supporter

Languages: English (English )

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

Sorry - I do not understand what you want me to do there? Could you please explain?

#1101621

Yes, to be more specific:
After testing we understood that we have to copy text value with logic:
[sht-cf-type] value from specific post (that is '5' in post ID '373') to post form '992' field [topic-mirror-id] should be like 'А.Н.Медведев - Группа Цигун...'

#1101635

Minesh
Supporter

Languages: English (English )

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

sorry - what you wrote is certainly not clear to me at all.

Do you mean when you save the form - you want to save the ID (that is '5' in post ID '373') and when display the form - show the text 'А.Н.Медведев - Группа Цигун...'?

#1101720

No, no, everything that been done - ok, we still need to put a text value into the form when we save it. The only adjustment - we should derive respective text value not from combination of TAG + CATEGORY - but ... from only one custom field [sht-cf-type] which is filled in every post or page...

#1102444

Minesh
Supporter

Languages: English (English )

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

Do you mean that all is working fine:

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

Now, you just need to save the value to database? If no - please explain in brief with step by step example and with few screenshot so that I can understand your requirement.

#1102464
tssupport-ticket-screen_4.png
tssupport-ticket-screen_5.png

Nope, please see my screenshots:

tssupport-ticket-screen_4 - I have post (ID=373) with custom field [sht-cf-type] value = ’Text for 9’ in it

tssupport-ticket-screen_5 - I have to copy TEXT VALUE to post form field

Ok?

#1102475

Minesh
Supporter

Languages: English (English )

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

well - I'm totally confused now. The form field you are showing - to that form field we already filled the value to it which is your original query.

Is this another requirement?

#1103258

Hmmm, I fixed it finally.

<div class="col-sm-12"><div class="form-group">
      [cred_generic_field field='tscf-topic-mirror' type='textfield' class='' urlparam='']
      {
      "required":0,
      "validate_format":0,
      "default":"[types field='sht-cf-type' id='POSTID' format=''][/types]",
      "persist":1,
      "readonly":1
      }
      [/cred_generic_field]</div></div>