MyBB Community Forums
Add a hook to usercp.php - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: MyBB 1.6 (https://community.mybb.com/forum-138.html)
+------ Forum: 1.6 General Support (https://community.mybb.com/forum-127.html)
+------ Thread: Add a hook to usercp.php (/thread-150429.html)



Add a hook to usercp.php - marcus123 - 2014-01-27

Is it possible to add a hook to usercp.php

Additional Information
Additional Contact Information


Fields?????


RE: Add a hook to usercp.php - Wildcard - 2014-01-27

Sounds like you just want to add some custom profile fields: ACP -> Configuration -> Custom Profile Fields


RE: Add a hook to usercp.php - marcus123 - 2014-01-27

Thanks buddy but I want to connect my plugin to those fields and prevent people from posting URLs


RE: Add a hook to usercp.php - Wildcard - 2014-01-27

Then just use:

$plugins->add_hook("usercp_do_profile_start", "my_function");

function my_function()
{
global $mybb;
// . . .
if (preg_match($regex, $mybb->input['profile_fields']['fid4'])) {
// filter here
}
}

You'll need to replace 'fid4' with 'fidX' X being the id of your new custom profile fields.


RE: Add a hook to usercp.php - marcus123 - 2014-01-27

Buddy I am using this to filter postbit message but what do I have to filter or connect to in there?
if(preg_match($regex, $post->data['message'], $match)



RE: Add a hook to usercp.php - Wildcard - 2014-01-27

I edited my answer. I had you on the wrong hook. Sorry.


RE: Add a hook to usercp.php - marcus123 - 2014-01-27

OMG dude I love you thanks very much you have just saved the DAY.
Saludos desde EspaƱa!

How to show an error message on the same page when this code has executed? I am referring to inline error

$message->set_error('ERROR'); doesn't work????