[Resolved] GPP 2.0 alpha – Cannot get author meta URL

Home Forums Support [Resolved] GPP 2.0 alpha – Cannot get author meta URL

Home Forums Support GPP 2.0 alpha – Cannot get author meta URL

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1680953
    George

    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.

    View post on imgur.com

    #1681276
    Elvin
    Staff
    Customer Support

    Hi there,

    You can try the User Meta.

    Here’s an example:
    https://share.getcloudapp.com/kpu7Z8o2

    Here’s what it could look like:
    https://share.getcloudapp.com/ApuRmXNN

    It 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.

    A wise man once said:
    "Have you cleared your cache?"

    #1681661
    George

    Ok, 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.

    View post on imgur.com

    For my button, I am setting it up like this:

    View post on imgur.com

    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:

    View post on imgur.com

    #1682279
    Tom
    Lead Developer
    Lead Developer

    Hey George,

    For some reason, WordPress has made it so some fields in the user profile can be fetched using get_user_meta(), and some require get_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 of get_user_meta().

    #1682287
    George

    Yes, 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!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.