New signups as followers

Eddy
Eddy
@eddy
9 years ago
479 posts
Hi it's been a while, I am back and using my jamroom as a blog this time, with the Lucid Skin, but I do have a couple of questions, I created a visitor quota just so users could leave comments, rate, share and follow my blogs, but is it possible to have new signups to that visitor quota follow me automatically? I'm using a quota called admin.

Thanks for your help.,

Eddy
updated by @eddy: 11/06/15 02:44:11PM
paul
@paul
9 years ago
4,326 posts
Hi Eddy - Welcome back.
There's no option to do this with Jamroom 'out of the box' but a pretty simple 'listener module' would do it.
The module will listen for the 'signup_activated' event then create the follower entry on the datastore.
Let me know if you need any help doing this.
Pa


--
Paul Asher - JR Developer and System Import Specialist
Eddy
Eddy
@eddy
9 years ago
479 posts
Yes I do Paul, I don't understand anything about php, I would really appreciate your help.
paul
@paul
9 years ago
4,326 posts
OK - Do this

Create a folder in the modules folder called 'jrAutoFollow'
In that folder create two files named 'config.php' and include.php'

In the config.php file enter this code -
<?php
/**
 * @copyright 2012 Talldude Networks, LLC.
 * @author Paul Asher <paul [at] jamroom [dot] net>
 */

// make sure we are not being called directly
defined('APP_DIR') or exit();

/**
 * jrAutoFollow_config
 */
function jrAutoFollow_config(){
    $_tmp = array(
        'name'      => 'followee',
        'label'     => 'Select Profile',
        'type'      => 'text',
        'help'      => 'Enter the ID of the profile that will be automatically followed upon signup',
        'validate'  => 'number_nz',
        'default'   => 1,
        'required'  => true
    );
    jrCore_register_setting('jrAutoFollow', $_tmp);

    return true;
}

?>

In the include.php file enter this code -
<?php
/**
 * @copyright 2012 Talldude Networks, LLC.
 * @author Paul Asher <paul [at] jamroom [dot] net>
 */

// make sure we are not being called directly
defined('APP_DIR') or exit();

/**
 * meta
 */
function jrAutoFollow_meta(){
    $_tmp = array(
        'name'        => 'Auto Follow',
        'url'         => 'autofollow',
        'version'     => '1.0.0',
        'developer'   => 'The Jamroom Network, &copy;' . strftime('%Y'),
        'description' => 'Automatically follow specified profiles upon signup',
        'category'    => 'profiles',
        'license'     => 'jcl'
    );
    return $_tmp;
}

/**
 * init
 */
function jrAutoFollow_init(){
    // Event Listener
    jrCore_register_event_listener('jrUser', 'signup_activated', 'jrAutoFollow_signup_activated_listener');

    return true;
}

//---------------------------------------------------------
// EVENT LISTENER
//---------------------------------------------------------

/**
 * Listen for the 'signup_activated' event and add user as a follower
 * @param $_data array incoming data array
 * @param $_user array current user info
 * @param $_conf array Global config
 * @param $_args array additional info about the module
 * @param $event string Event Trigger name
 * @return array
 */
function jrAutoFollow_signup_activated_listener($_data, $_user, $_conf, $_args, $event)
{ $_tmp = array( 'follow_active' => 1, 'follow_profile_id' => $_conf['jrAutoFollow_followee'] ); $_core = array( '_profile_id' => $_data['_profile_id'], '_user_id' => $_data['_user_id'] ); jrCore_db_create_item('jrFollower', $_tmp, $_core); return $_data; }

Goto your ACP then in the Profiles section enable this new module.
In its config section enter the ID of the profile to be auto-followed.

Done :-)


--
Paul Asher - JR Developer and System Import Specialist
Eddy
Eddy
@eddy
9 years ago
479 posts
Thank you Paul, awesome!

Great support as always.

Eddy

Tags