EllisLab text mark
Advanced Search
     
Check if Member Exists
Posted: 18 August 2012 12:48 AM   [ Ignore ]
Avatar
Joined: 2011-07-19
66 posts

I need to check if a number, a segment in the url, is linked to a member id. What is the best way to find out if a member exist?

Currently, if the user messes with the url segment with a number that doesnt exist, the profile then puts in null data to a template.

 
Posted: 20 August 2012 01:13 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi Reverie123,

I’m sure there’s a way, but to get you the best answer in this instance, can I see what you already have in your template? As well as the ExpressionEngine version and whether or not you are using any 3rd part membership add ons like User or Visitor.

Thanks!

 Signature 

How may I help you?

 
Posted: 20 August 2012 01:37 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2011-07-19
66 posts

I have the user module, as for the template

<!-- MEMBER check -->

 
{if segment_3}
  
  {exp
:members}
    {single_member id
="{segment_3}"}
     {if m_group_id 
!= "{embed:group_name_type}" {embed:group_admin}}
      {redirect
="{site_url}"}
     {if
:else} 
      
<div>{m_group_id}</div>
     
{/if}
    {
/single_member}
   {
/exp:members} 
   
 {if
:else}
  {redirect
="{site_url}"}
  
 {
/if}
 
 
<!-- MEMBER check END --> 

This to make sure that if the url is changed with the incorrect member id, it won’t populate the template with the wrong data. I just need to put in a check if the user exists or not, because they could place a false number in there and just populate the template with no data.

 

 
Posted: 20 August 2012 05:53 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-07-19
66 posts

I figured it out, and I feel extra stupid as user has those features built in and I don’t need any add-ons.

 
Posted: 21 August 2012 11:48 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Reverie123,

I figured it out…

Awesome! I love reading that!

Indeed, User has some nice features. Nice to see it come through for you!

If you need anything else, please let us know.

~

 Signature 

How may I help you?