How do you adjust this for another value please?

Hi all, Happy Easter and isn’t it great to have a brilliant excuse to eat all those chocs!! :slight_smile: Anyways, can anyone help on this? Have been trying for a few weeks to get this right, need to do it so that it’s a pre-requisite to do 100 posts to post an email address and 50 posts to post a website address.

if ($submit || $preview || $refresh)
{

    if ($user->data['user_posts'] < 100)
       {
          if (preg_match('/(http|www|dotcom|dotcodotuk)/i', request_var('message', '', true)))
          {
             $error[] = $user->lang['NO_URLS'];
          }
      	 if (preg_match('/(@)/i', request_var('message', '', true)))
      	  {
             $error[] = $user->lang['NO_EMAILS'];
          }

       
       }

if ($submit || $preview || $refresh)
    if ($user->data['user_posts'] < 100){

          if (preg_match('/(http|www|dotcom|dotcodotuk)/i', request_var('message', '', true)))
             $error[] = $user->lang['NO_URLS'];

          if($user->data['user_posts'] < 50)
              if (preg_match('/(@)/i', request_var('message', '', true)))
                  $error[] = $user->lang['NO_EMAILS'];
       
       }

I believe this is what you mean?

Also, your regex are a bit off, I would suggest looking into filter_var

Thanks Kokos, although, just tried it and got: Parse error: syntax error, unexpected ‘}’

I’m using shorthands there to avoid excess brackets, this piece of code alone shouldn’t give that error but combined with your own code it could (if there is a ‘}’ left from your previous code that shouldn’t be there).

Here is the same code without shorthands:


if ($submit || $preview || $refresh){

    if ($user->data['user_posts'] < 100){

          if (preg_match('/(http|www|dotcom|dotcodotuk)/i', request_var('message', '', true))){

             $error[] = $user->lang['NO_URLS'];

          }

          if($user->data['user_posts'] < 50){

              if (preg_match('/(@)/i', request_var('message', '', true))){

                  $error[] = $user->lang['NO_EMAILS'];
          
              }

          }  
       
       } 

}

Many thanks - much appreciated - all solved :slight_smile: