• [ Moderator note: moved to Fixing WordPress. ]

    Actually my requirement is, When ever any user registered in my websites the also add in my AWeber mailing list subscription. How i can achieve this functionality in my websites. currently this functionality is working in https://www.ads-software.com on create account page. Please help me how we can achieve from by plug in or by scratch. Thanks

Viewing 1 replies (of 1 total)
  • Joey

    (@leglesslizard)

    Hi there,

    I’m not clued up on AWeber but have had a look through the plugin. There appears to be 2 functions to have a look at:

    function grab_email_from_registration()
        {
            if ($_POST['aweber_signup_checkbox'] != 1)
                return;
            if(isset($_POST['user_email'])) {
                $email = $_POST['user_email'];
                $user = $_POST['user_login'];
                $ip = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
                $options = get_option($this->widgetOptionsName);
                $sub = $this->create_subscriber($email, $ip, $options['list_id_create_subscriber'], '');
            }
        }

    And

    function create_subscriber($email, $ip, $list_id, $name)
        {
            $admin_options = get_option($this->adminOptionsName);
            try {
                $aweber = $this->_get_aweber_api($admin_options['consumer_key'], $admin_options['consumer_secret']);
                $account = $aweber->getAccount($admin_options['access_key'], $admin_options['access_secret']);
                $subs = $account->loadFromUrl('/accounts/' . $account->id . '/lists/' . $list_id . '/subscribers');
                return $subs->create(array(
                                        'email' => $email,
                                        'ip_address' => $ip,
                                        'name' => $name,
                                        'ad_tracking' => 'Wordpress',
                                    ));
            }
            catch (Exception $exc) {
                #List ID was not in this account
                if ($exc->type === 'NotFoundError') {
                    $options = get_option($this->widgetOptionsName);
                    $options['list_id_create_subscriber'] = null;
                    update_option($this->widgetOptionsName, $options);
                }
                #Authorization is invalid
                if ($exc->type === 'UnauthorizedError')
                    $this->deauthorize();
            }
        }

    I believe the best way to go about this would be to create a custom plugin that checks that the AWeber plugin exists and then rewrite the first function (as there are no hooks available to utilise it and you’d have to override the $_POST array to ensure it ran correctly). Your rewritten function would be very similar to the original but just omitting any irrelevant code.
    Then you can invoke the second function (as the first does anyway) and this, I believe, will create your subscriber as the original plugin does.

    To hook this functionality up at the desired time have a look at wordpress hooks that are available when a user registers. For example:
    do_action( 'user_register', $user_id );

    This is called whenever a new user is successfully registered.

    Hope this helps some!

    Regards,
    Joey

Viewing 1 replies (of 1 total)
  • The topic ‘I want user registration with Subscribe to our Aweber mailing list’ is closed to new replies.