Skip Navigation

[Resolved] Custom Author archive pages per user role.

This support ticket is created 3 years 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
- 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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 3 years ago.

Assisted by: Waqar.

Author
Posts
#2279453

Im trying to create different author archive pages for different roles that display content from users.
I know how to display the content already but i don't know how to setup multiple archive pages and link them to the user role.
Preferably i would like to user Elementor to design the different author archive pages + add dynamic content.

Can you help me set it up?
Thanks!

#2279805

Hi,

Thank you for contacting us and I'd be happy to assist.

Toolset doesn't support the assignment of different WordPress Archives for authors, based on their user roles. For this, you'll need some workaround.

1. You can register a custom shortcode, that can accept the target's user role in the shortcode attribute and then return '1', if the current author on the author archive page, has that role and '0', if not:


add_shortcode('custom_author_role_check', 'custom_author_role_check_func');
function custom_author_role_check_func( $atts ) {
	$data = shortcode_atts( array(
		'role' => ''
	), $atts );

	if(!empty($data['role'])) {
		$arhive_author = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));

		$author_roles = $arhive_author->roles;
		
		if (in_array($data['role'], $author_roles) ){
			return '1';
		} else {
			return '0';
		}
	}
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

2. Next, please add "custom_author_role_check" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.

3. In the last step, you can include the conditional blocks in the Toolset's WordPress Archive for the authors, to show/hide different content items, based on the user role.

For example, to show some content, only if the author archive is for the role "editor", the conditional statement will look like this:


( ( '[custom_author_role_check role=editor]' eq '1' ) ) 

I hope this helps and please let me know if you need any further assistance around this.

Note: To confirm if Elementor supports the assignment of user role-based author archives, it would be best to consult its official support and documentation.

regards,
Waqar