Skip Navigation

[Resolved] "Call to undefined function types_render_field_single" call from another plugin

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by ivayloK 8 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#294977

Hello,

when I call the function types_render_usermeta_field("auszubildende-r-zum-zur", array('show_name' => 'true','user_id' => $user->user_id)) from another plugin like author-avatars I receive an error message: PHP Fatal error: Call to undefined function types_render_field_single() in ... on line 681. The message comes only when I click the save button for a page in wp backend. On this page I have a shortcode which loads the plugin for the frontend -> [authoravatars avatar_size=35 show_name=true show_biography=true]
http://wordpress.org/plugins/author-avatars/

My question is, how can I make a call to a custom user field in other plugin.
When I try the solutions from this post -> https://toolset.com/forums/topic/user-fields-select-option-display-text/ I receive the above described error and the result is not the same as in a theme file. As a result I receive only the firs option value of the select box.
When I try this one

"auszubildende-r-zum-zur", array('show_name' => 'true','user_id' => $user->user_id))

I get the value="5" of the selected option, in this case -> 5

Thank you very much,
Ivaylo

#295270

Dear Ivaylo,

I suggest you try wordpress function get_user_meta(), for example:

get_user_meta($user->user_id, 'wpcf-auszubildende-r-zum-zur', true);

More help:
get_user_meta
Retrieve a single meta field or all fields of user_meta data for the given user. Uses get_metadata(). This function replaces the deprecated get_usermeta() function.
http://codex.wordpress.org/Function_Reference/get_user_meta

#295280
Bildschirmfoto 2015-04-13 um 11.43.51.png

Hi luoy,

sry for the broken code example. It should look like this one:

print_r(types_render_usermeta_field("auszubildende-r-zum-zur", array('show_name' => 'true','user_id' => $user->user_id)));

However, I tried your suggestion:

print_r(get_metadata('user', $user->user_id, 'wpcf-auszubildende-r-zum-zur', true ));

It gave me the following result:
1531111

These are the ids of the possible options in the types select element (see screenshot).
How can I retrive the value of the selected selectbox option, for example: "Luftverke..."

Thank you very much!
Ivaylo

#295553

You can call Types function only after Types was loaded in wordpress, you can try Types action hook wpcf_after_init, like this:

add_action('wpcf_after_init', 'call_types_function');
function call_types_function(){
	if(function_exists ('types_render_usermeta_field') && !is_admin()){
		print_r(types_render_usermeta_field("auszubildende-r-zum-zur", array('show_name' => 'true','user_id' => 1)));
// your custom codes goes here...
	}
}
#299597

Hi,

I fixed the issue with this one:

if(do_shortcode('[types usermeta="auszubildende-r-zum-zur" user_id="' . $user->user_id . '"] [/types]') != '--- bitte auswählen ---') {
					//echo substr_replace(types_render_usermeta_field("auszubildende-r-zum-zur", array('show_name' => 'true')), "", -3);
					$biography = do_shortcode('[types usermeta="auszubildende-r-zum-zur" user_id="' . $user->user_id . '"] [/types]');
					//echo do_shortcode('[types usermeta="auszubildende-r-zum-zur"] [/types]');
				}

Thank you!!!

The forum ‘Types Community Support’ is closed to new topics and replies.

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