Is there some way to edit the PHP files so that the pop up appears to users who havent logged in?
I'm using this as a cookie warning.
Solved it myself.
Is there some way to edit the PHP files so that the pop up appears to users who havent logged in?
I'm using this as a cookie warning.
I fixed it myself. My solution was to add a " || " variable in the " if " function in UserAgreementHooks.php.
So this:
if ( $userId > 0 && $userUAAcceptedDate <= $uaModifiedDate) {
I changed to this:
if ( $userId > 0 && $userUAAcceptedDate <= $uaModifiedDate || $_COOKIE['ua']!= "1" ) {
Now it checks for a cookie named "ua", it wants to have the value "1"
Then I added this little snippet in renderUserAgreement.js:
$("#uaAccept").click( function () {
var api = new mw.Api();
api.post({
action: 'uaAcceptAgreement',
token: mw.user.tokens.get( 'editToken' ),
}).done(function(data) {
document.cookie = "ua=1";
location.reload(true);
It's pretty simple, but works for me. Note that the user check is pretty much overwritten now, it always checks for a cookie.
If you change your policy and want all users to agre, well, then it wouldnt show up... One solution to that is maybe to change the variable "1" to something else, like 2 maybe...
Edit: The cookie is eternal and wont expire, you can add a timestamp in the .js file when creating the cookie.