- This topic has 4 replies, 3 voices, and was last updated 3 years, 1 month ago by George.
-
AuthorPosts
-
March 3, 2021 at 1:34 pm #1680953George
I have filled the URL field for my user but I can’t seem to retrieve the field data through a dynamic button. I am using a post template meta block and created an author card. I have also created a few custom user meta social links:
add_filter( 'user_contactmethods','wpse_user_contactmethods', 10, 1 ); function wpse_user_contactmethods( $contact_methods ) { $contact_methods['facebook'] = __( 'Facebook URL', 'text_domain' ); $contact_methods['twitter'] = __( 'Twitter URL', 'text_domain' ); $contact_methods['linkedin'] = __( 'LinkedIn URL', 'text_domain' ); $contact_methods['jobtitle'] = __( 'Job title', 'text_domain' ); return $contact_methods; }
The URL or website field is already included as a user meta in WP core anyway. I have created buttons like in the picture attached. The post author meta I custom-coded works fine but the URL meta when inserted as a dynamic link, hides the button completely in the front-end.
March 3, 2021 at 10:06 pm #1681276ElvinStaffCustomer SupportHi there,
You can try the User Meta.
Here’s an example:
https://share.getcloudapp.com/kpu7Z8o2Here’s what it could look like:
https://share.getcloudapp.com/ApuRmXNNIt literally just takes the value added to the field. 🙂
Simply replace
'facebook'
with all the other contact methods you’ve added for each meta you’ll be adding.March 4, 2021 at 5:25 am #1681661GeorgeOk, I will try and explain again. First of all, I don’t know what version of GPP 2.0 you use (I am using the latest alpha) but there is not a “User Meta” dynamic text type. There is only an “Author meta” as shown in my previous post.
Now, as I mentioned, I use dynamic buttons and not headings (but that shouldn’t make any difference). As I also mentioned, I am able to use the “Author meta” to display dynamic links for the custom meta I have created with the code provided. As you can see, the code DOES NOT include the website meta field since there is already one in WordPress as a built-in user meta field.
So you can forget the code I mentioned if this is going to make it easier to understand. All I am interested in right now is displaying the “Website” field. I have created buttons with custom SVG icons. I am not interested in displaying the field in the icon but rather having a DYNAMIC LINK attached to the button. I make the assumption that the meta name is “url” since I inspected the field in the user admin page.
For my button, I am setting it up like this:
Again, I am NOT setting “dynamic text type” since I have already the button icon already displayed. I do want the dynamic link to be able to apply to the button. Instead, I am getting nothing on the front. All the other buttons work fine:
March 4, 2021 at 10:51 am #1682279TomLead DeveloperLead DeveloperHey George,
For some reason, WordPress has made it so some fields in the user profile can be fetched using
get_user_meta()
, and some requireget_userdata()
. I have no idea why – perhaps it’s some old back-compat issues.I’ll have to think on how to get the plugin to know which one to use. In this case, the URL field uses
get_userdata()
instead ofget_user_meta()
.March 4, 2021 at 10:54 am #1682287GeorgeYes, I also noticed this behavior with some other user meta, Tom, so your observation makes sense. I will settle with creating a shortcode for the time being.
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.