Last active
December 22, 2015 10:58
-
-
Save benheu/6462152 to your computer and use it in GitHub Desktop.
This is a sample function showing how to get a link toward the "Manage your subscriptions page" in Wysija http://wordpress.org/plugins/wysija-newsletters/description/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is a sample function showing how to get a link toward the "Manage your subscriptions page" in Wysija (http://wordpress.org/plugins/wysija-newsletters/description/) | |
* You'll need to call that function at a moment where Wysija's classes are already loaded otherwise it won't work | |
* @return subscription link for the current logged in WordPress' user | |
*/ | |
function wysija_get_subscriptions_edit_link(){ | |
// wysija classes ar enot loaded so we can't use that function | |
if (!class_exists('WYSIJA')){ | |
return; | |
} | |
// let's get the current WordPress user ID | |
$model_user = WYSIJA::get('user','model',false,'wysija-newsletters',false); | |
$model_user ->getFormat=OBJECT; | |
$wpuser_id = WYSIJA::wp_get_userdata('ID'); | |
// there is no logged in WordPress user | |
if (empty($wpuser_id)){ | |
return; | |
} | |
// let's try to get the corresponding Wysija's subscriber to that WordPress' user ID | |
$user_object = $model_user ->getOne(false,array('wpuser_id'=>$wpuser_id)); | |
if (empty($user_object)){ | |
return; | |
} | |
// we return the subscription link for that user | |
return $model_user ->getConfirmLink($user_object,'subscriptions',false,true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment