Skip Navigation

[Resolved] Author role = guest

This support ticket is created 6 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Bochnacki 6 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#548094

How can I rewrite the code:

add_shortcode( 'author-role', function(){
    global $post;
    $author_id = $post->post_author;
    $author_meta = get_userdata( $author_id );
    $author_roles = $author_meta->roles;
    return $author_roles[0];
});

to run shortcode [wpv-conditional if="( '[author-role]' eq 'guest' )"] ?

#548196

Dear Bochnacki,

The "guest" isn't a logged-in wordpress user, so there should not be any posts whose author is a guest user.

If you need to check if current user is a logged-in and then display something based on that condition, please check our document:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/#40c1d

#548455

Of course you are generally right. But I allow the purchase of posts by guests not logged in. As a result, there are a few elements that I need to assign them somehow.
Some positions I managed to "work around", but with some problems.
Well, I will be combining since there is no other solution 🙂

Thanks 🙂

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