MyBB Community Forums

Full Version: Why can't I edit member_profile_modoptions on _activate?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm working on a plugin to report spammers and I want to add a link to it from the Moderator Options section in the user profile.

I have this code in _activate:
// Make the plugin "visible" by adding and changing templates
function report_spammer_activate()
{
	require_once MYBB_ROOT . 'inc/adminfunctions_templates.php';
	find_replace_templatesets('member_profile_modoptions', '#b#i', 'not working', 0);  // WTF
	
	find_replace_templatesets('modcp_editprofile', '#({\$lang->moderation}.*?</tr>\s*</table>\s*</fieldset>)#si', '$1' . "\n" . '{$report_spammer}', 1);  // works
}

The second template (modcp_editprofile) gets modified. The member_profile_modoptions template isn't modified, even though there are a lot of b's in it.

Is this template read-only or what?[/php]
There's nothing special about this template or any template... is there a reason you're including the 0 at the end?? You generally only need the 4th parameter when undoing the edits. I mean for the one that works you've got that parameter set to 1 and for the one that doesn't work it's set to 0, so see what it does when you take that out...
Thank Matt! I'd read in the find_replace_templatesets() docs that the 4th parameter is for autocreating templates:

Quote:Set to 1 to automatically create templates which do not exist for that set (based off master)

And I thought I didn't want that template autocreated if it didn't exist, but because I'm using a theme which doesn't include that template, the function didn't pull it in from "master" (the Default templateset, I guess).