Wordpress no permission redirection to a popup
I am currently using a custom code where if there is no permission, it will redirect to a need permission page. However I would like to transform this to a popup instead of redirection.
Below is the base of my code:
function redirect_users() {
//check permission here
if( !$permission ) {
wp_redirect( 'no-permssion-page' );
exit;
}
}
redirect_users();
Basically, when users click on any element with a redirect function(a tag, button, etc), it will run a function and then if there is no permission, a popup will appear.
- I am asking if there is such a plugin that will open a popup based on permission access.
If there is no such plugin, what I was thinking is to create an ajax function and attach it to all a tag. Then check if there is a permission or not before the actual redirection.
Something like this:
jQuery('a').click( function(e) {
e.preventDefault();
if (this.href != '' this.href != undefined) {
// ajax check permission
alert(do some ajax anchor);
location.href = this.href;
}
});
jQuery('.btn').click( function(e) {
e.preventDefault();
alert(do some ajax button);
// ajax check permission
// location.href = this.href;
});
- if there is no plugin, is there a better alternative to the code that I am trying to make?
Topic redirect plugin-recommendation Wordpress
Category Web