Support

Home Forums Event Espresso Premium Restrict event details if no Member Role assigned

Restrict event details if no Member Role assigned

Posted: August 9, 2023 at 12:59 pm

Viewing 7 reply threads


Amy

August 9, 2023 at 12:59 pm

I can restrict the tickets based on roles and capabilities but is there a way to restrict event descriptions? Currently I use [members_logged_in] to hide information but anyone can see the content as long as they are logged in. I want to use the same capability as the ticket. currently for the ticket I’m using ee_read_private_events.

Thanks!


Amy

August 9, 2023 at 1:02 pm

Also, where is [members_logged_in] defined?


Amy

August 9, 2023 at 2:25 pm

It looks like I have this customization. I can’t tell how it’s getting into the shortcode above. But looks like I can add another or statement to hide if user is “Subscriber Role”.

/* display members only message */
function display_members_only_msg() {
   $html = '<i>Members only</i>' ;
   return $html ;
}

function display_protected_content() {
	if ( is_user_logged_in()  ) {
	    $user = wp_get_current_user();
		$user_role = $user->roles[0];	/* get user roles */
		/* if no role or expired don't show content, otherwise do show content */
	    if ( $user_role == 'expiredmember' or $user_role <= '  1') { 
			return False;
		} else { 
		 	return True; 
		}
	} else { /* show content if first word of estract is 'Public' */
		if ( substr(get_the_excerpt(),0,6) == 'Public' ) {
			return True;
		} else {
			 return False;
		}
	}
}


Tony

  • Support Staff

August 9, 2023 at 2:37 pm

Also, where is [members_logged_in] defined?

Thats not from Event Espresso, I’m guessing part of the customization you mentioned above but the code for it is not included there.

I can’t tell how it’s getting into the shortcode above.

There must be more to that code, as it is that just some functions with nothing calling them?


Amy

August 9, 2023 at 2:52 pm

Yes, we call the functions in the ee event template in the child theme customization files.


Tony

  • Support Staff

August 9, 2023 at 3:08 pm

Ok, so a quick google search shows the [members_logged_in] shortcode is from the ‘Members’ plugin

https://members-plugin.com/docs/shortcodes/

Looking at the doc there it looks like it has the features you need for this?

Or am I misunderstanding your question here?


Amy

August 9, 2023 at 3:15 pm

Okay, great! Looks like the code above I need to update to hide the ee sections, venue, people, etc and Members_logged_in is separate. The link you provided is exactly what I needed. Thanks!


Tony

  • Support Staff

August 9, 2023 at 3:38 pm

Awesome, I’m glad that helped 🙂

Viewing 7 reply threads

The support post ‘Restrict event details if no Member Role assigned’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso