Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 10 Years, 9 Months, 3 Weeks ago PHP expert please help
#1
Solved: 10 Years, 9 Months, 3 Weeks ago
I am trying to check user filed fid6 if they are entering Facebook URL or some other one by can't make it work please help?

function cpfbbcode()
{
    global $mybb;


    $cpfbbcode = 'facebook.com';
    
        if(preg_match("/$cpfbbcode/", $userfields['fid6'], $match))
        {
		}
		else
		{
    
            error("some error");

        }
        }
#2
Solved: 10 Years, 9 Months, 3 Weeks ago
if you dont need a complex search just use str_pos() instead

if(str_pos($userfields['fid6'], $cpfbbcode))
Lost interest, sold my sites, will browse here once in a while. It's been fun.
#3
Solved: 10 Years, 9 Months, 3 Weeks ago
if(preg_match('#https?\://(?:www\.)?facebook\.com/(\d+|[A-Za-z0-9\.]+)/?#',$userfields['fid6'],$matches))
{
}

.
.
#4
Solved: 10 Years, 9 Months, 3 Weeks ago
This is what I'd do:

function cpfbbcode()
{
	global $mybb, $db;
	
	$cpfbbcode = 'facebook.com';
	$uid = $mybb->user['uid'];
	
    $ufid = $db->fetch_assoc($db->simple_select('userfields', 'fid6', 'ufid = '.$uid));
	if(str_pos($ufid['fid6'], $cpfbbcode))
	{
		success("Valid");
	}
	else
	{
		error("Invalid");
	}
} 
#5
Solved: 10 Years, 9 Months, 3 Weeks ago
Dear @pavemen, @effone and @Tankey thank you so much for your support I don't want to offend anybody so I won't choose best answer as they are all great ones! +1 for all of you Smile

Guys please one more question is this the correct hook

$plugins->add_hook("usercp_do_profile_end", "cpfbbcode");

Just checked all you codes return error Smile
#6
Solved: 10 Years, 9 Months, 3 Weeks ago
Please guys how to make your code work? Or maybe tell me how to check
$userfields['fid6']
or user profile field
fid6
to see if user has entered facebook URL or some other?

Maybe something like this one?

function cpfbbcode()
{
    global $mybb;


    $cpfbbcode = 'facebook.com';
    
        if(strpos($userfields['fid6'], $cpfbbcode) !== false) 
        {
        
            error("some error");

        }
        } 
#7
Solved: 10 Years, 9 Months, 3 Weeks ago
$userfields is not available, add it to the global list.
Lost interest, sold my sites, will browse here once in a while. It's been fun.
#8
Solved: 10 Years, 9 Months, 3 Weeks ago
Thanks man by could you please post a complete code please
#9
Solved: 10 Years, 9 Months, 3 Weeks ago
The above just means replacing

global $mybb;

with

global $mybb, $userfields;
#10
Solved: 10 Years, 9 Months, 3 Weeks ago
Thanks from all the above which one do you think i should use to check if user has entered facebook URL not some other

PLease could anybody create a plugin because I have no idea how to make it work
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)