Ultimate Member – Show List of Posts (Post Type) by all users that current logged in user follows

I am new to the ‘Ultimate Member’ plugin and I am using the ‘UM Followers’ extension plugin.

My users can all generate posts (post type).

I would like to set up a page-template in which the current logged in user can see a list of all posts sorted by most recent, only by users that he/she follows.

I had a look at the following template that generates a list of users using their avatars. But can’t figure out how I could use this to generate the list of posts by users my logged in user follows.

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( $following ) {

    foreach ( $following as $k => $arr ) {
        /**
         * @var $user_id1;
         */
        extract( $arr );

        um_fetch_user( $user_id1 ); ?>
    
        <div class="um-followers-user">
    
            <a href="<?php echo esc_url( um_user_profile_url() ); ?>" class="um-followers-user-photo" title="<?php echo esc_attr( um_user( 'display_name' ) ); ?>">
                <?php echo get_avatar( um_user('ID'), 50 ); ?>
            </a>
        
            <div class="um-followers-user-name">
                <a href="<?php echo esc_url( um_user_profile_url() ); ?>" title="<?php echo esc_attr( um_user('display_name') ); ?>">
                    <?php echo esc_html( um_user( 'display_name' ) ); ?>
                </a>
            
                <?php do_action('um_following_list_post_user_name', $user_id, $user_id1 );

                if ( um_user( 'ID' ) == get_current_user_id() ) { ?>
                    <span class="um-followers-user-span"><?php _e( 'You', 'um-followers' ); ?></span>
                <?php } elseif ( UM()->Followers_API()->api()->followed( get_current_user_id(), $user_id1 ) ) { ?>
                    <span class="um-followers-user-span"><?php _e( 'Follows you', 'um-followers' ); ?></span>
                <?php }

                do_action('um_following_list_after_user_name', $user_id, $user_id1 ); ?>
            </div>
        
            <div class="um-followers-user-btn">
                <?php if ( $user_id1 == get_current_user_id() ) {
                    echo '<a href="' . esc_url( um_edit_profile_url() ) . '" class="um-follow-edit um-button um-alt">' . __( 'Edit profile', 'um-followers' ) . '</a>';
                } else {
                    echo UM()->Followers_API()->api()->follow_button( $user_id1, get_current_user_id() );
                } ?>
            </div>
        
            <?php do_action( 'um_following_list_pre_user_bio', $user_id, $user_id1 ); ?>
        
            <div class="um-followers-user-bio">
                <?php echo um_get_snippet( um_filtered_value( 'description' ), 25 ); ?>
            </div>
        
            <?php do_action( 'um_following_list_post_user_bio', $user_id, $user_id1 ); ?>
        
        </div>
    
    <?php }

} else { ?>

    <div class="um-profile-note">
        <span><?php echo ( $user_id == get_current_user_id() ) ? __( 'You did not follow anybody yet.', 'um-followers' ) : __( 'This user did not follow anybody yet.', 'um-followers' ); ?></span>
    </div>

<?php }```

thanks to anyone who could assist :)

Member Watch

AnimeHaxor submitted a new resource:

Member Watch – Watch a member and get alert notification on his post new thread or reply.

Functions​

  • Watch a Member get alert notifications of his activity like post a new thread or reply.
  • Watched Member will also get a notification as alert user X watching him.
  • In User preference, there are options to select to…

Read more

.

php – Response: 500 – Call to a member function update() on null

Estou tendo esse problema ao tentar usar o registro no api da Uppo.

<?php

namespace AppApiV2ControllersAuth;

use AppApiV2ModelsUser;
use AppApiV2ModelsBenefit;
use AppApiV2NotificationsSendResetPasswordLinkNotification;
use AppApiV2NotificationsWelcomeNotification;
use AppApiV2RepositoriesClubClubRepository;
use AppApiV2RepositoriesBenefitBenefitRepository;
use AppApiV2RepositoriesInviteInviteRepository;
use AppApiV2RepositoriesSocialSocialRepository;
use AppApiV2RepositoriesUserUserRepository;
use AppApiV2ResourcesUserPublicResource;
use AppApiV2RulesInvitableRule;
use AppApiV2RulesSecretRule;
use DingoApiExceptionStoreResourceFailedException;
use DingoApiExceptionValidationHttpException;
use IlluminateValidationUnauthorizedException;
use AppApiV2ModelsDeviceToken;
use Validator;
use IlluminateHttpRequest;
use TymonJWTAuthJWTAuth;
use AppHttpControllersController;
use DB;
use Mail;
use oliveready7LaravelSesSesMail;
use AppApiV2UtilsEmailVerificationStatus;
use GuzzleHttpClient as GuzzleClient;
use AppApiV2ModelsSettings;
use AppApiV2ModelsUserSubscription;
use AppApiV2LibrariesCheckSubscriptionStatus;

class RegisterController extends Controller
{
    protected $userRepository;
    protected $jwtAuth;
    protected $inviteRepository;
    protected $clubRepository;
    protected $socialRepository;
    protected $benefitRepository;

    function __construct(
        UserRepository $userRepository,
        JWTAuth $jwtAuth,
        InviteRepository $inviteRepository,
        ClubRepository $clubRepository,
        SocialRepository $socialRepository,
        BenefitRepository $benefitRepository
    )
    {
        $this->userRepository = $userRepository;
        $this->jwtAuth = $jwtAuth;
        $this->inviteRepository = $inviteRepository;
        $this->clubRepository = $clubRepository;
        $this->socialRepository = $socialRepository;
        $this->benefitRepository = $benefitRepository;
    }

    public function register(Request $request)
    {
        $data = $request->except('type');
        use Request;
        
        $emailVerificationStatus = new EmailVerificationStatus();
        $club = $this->clubRepository->getPublicSimpleInfo($request->route('slug'));
        if (!$club) {
            throw new ResourceNotFoundException('Club not found.');
        }
        // $club->image = $club->logo->url;
        // $club->logoUrl = $club->logo->url;
        $url = env('APP_URL') . $club->slug;

        if ($club->integration) {
            unset($data('code'));
        }

        if($club->slug == 'union'){
            $validator = $this->userRepository->validateCreateForUnion($data);
        }else if($club->slug == 'plusclubedevantagens' || $club->slug == 'clubegaruper'){
            $validator = $this->userRepository->validateCreateForPlusclubedevantagens($data);
        }else if($club->slug == 'powerbeneficios'){
            $validator = $this->userRepository->validateCreateForPowerbeneficios($data);
        }else{
            $validator = $this->userRepository->validateCreate($data);
        }

        if(isset($data('code'))){
            if($club->slug == 'clubefacility' || $club->slug == 'plusclubedevantagens' || $club->slug == 'clubegaruper'){
                $data('cpf') = $data('code');
            }
        }
        
        if ($validator->fails()) {
            throw new ValidationHttpException($validator->errors()->toArray());
        }

        /** @var User $user */
        // if (!$user = $this->userRepository->create($request->except('type'))) {
        $data('email_verification_token') = str_random(25);
        // $data('email_verification_status') = EmailVerificationStatus::Email_Verification_Pending;
        $data('email_verification_status') = EmailVerificationStatus::Email_Verfied;
        $userData = User::where('email',$data('email'))->first(); 
        if(!$userData){
            if (!$user = $this->userRepository->create($data)) {
                throw new StoreResourceFailedException('Could not create the user.');
            }
        }else{
            $userData->name = $data('name');
            $userData->email = $data('email');
            $userData->password = $data('password');
            $userData->login_type = $data('login_type');
            $userData->folha_access_token = $data('folha_access_token');
            $userData->expires_in = $data('expires_in');
            $userData->refresh_token = $data('refresh_token');
            $userData->save();
            $user = $userData;
        }
        $user = User::where('email',$data('email'))->first();
        if($request->route('slug') != 'powerbeneficios' && $request->route('slug') != 'rebeneficios'){
            if ($request->code && $club->auth === 'code' && $club->code != 'cnpj') {
                $this->inviteRepository->useOne($request->all());
             }
        }
        

        if ($request->social && $request->provider) {
            $socialData = (
                'provider' => $request->provider,
                'value' => $request->social,
                'user_id' => $user->id,
                'club_id' => $request->club_id
            );
            $this->socialRepository->create($socialData);
        }

        $token = $this->jwtAuth->fromUser($user);
        // $verification_link = env('APP_URL').$club->slug.'/verify-email/'.$user->email_verification_token;
        // Session::put('club_id',$club->id);
        // SesMail::enableAllTracking()->setBatch('Email de verificação do usuário')->send('emails.verify_email', ('user' => $user, 'club' => $club, 'verification_link' => $verification_link), function ($m) use($user, $club) {
        //     $m->from(env('MAIL_NO_REPLY'));
        //     $m->to($user->email)->subject("$club->name - Verifique seu e-mail para concluir o cadastro!");
        // });

        // $user->notify(new WelcomeNotification());
        
        // For Welcome Email
        $isEmailValid = $emailVerificationStatus->EmailValidityIntegration($user->email);
        if(!!$isEmailValid && $club->email_auto != 1){
            Session::put('club_id',$club->id);
            Mail::send('emails.welcome-notification', ('club' => $club,'url'=>$url), function ($m) use ($club,$user)
            {
                $m->from(env('MAIL_NO_REPLY'),$club->name);
                $m->to($user->email)->subject('('.$club->name.') - Bem-vindo!');
            });
            // SesMail::enableAllTracking()->setBatch('E-mail de boas-vindas')->send('emails.welcome-notification', ('club' => $club,'url'=>$url), function ($m) use ($club,$user)
            // {
            //     $m->from(env('MAIL_NO_REPLY'));
            //     $m->to($user->email)->subject('('.$club->name.') - Bem-vindo!');
            // });
        }

        if($request->route('slug') === 'vitrineconecta') { //For vitrineconecta only
            $cities = $this->benefitRepository->getBenefitsCitiesByClub($club->id);     
            $data ('cities') = $cities;
        }
        
        if(!array_key_exists('device_type',$data)){
            $data('device_type') = "";   
        }
        if(!array_key_exists('device_token',$data)){
            $data('device_token') = "";   
        }
        $deviceTokenData = (
            'club_id' => $data('club_id'),
            'user_id' => $user->id,
            'device_type' => $data('device_type'), 
            'device_token' => $data('device_token') 
        );
        if($user->type == 'admin'){
            $deviceTokenData('user_type') = 1;
        }else{
            $deviceTokenData('user_type') = 2;
        }
        if($data('device_type') != '' && $data('device_token') != ''){
            $deviceToken = DeviceToken::where('user_id',$deviceTokenData('user_id'))->where('club_id',$deviceTokenData('club_id'))->where('device_token',$deviceTokenData('device_token'))->first();
            if($deviceToken){
                $deviceToken->delete();
            }
            DeviceToken::create($deviceTokenData);
        }
        $data('access_token') = $token;
        $userData = new PublicResource($user);
        $checkstatus = new CheckSubscriptionStatus();
        $subscriptionStatus = $checkstatus->checkSubscriptionStatus($club->id,$userData->id);
        // $subscriptionStatus = $this->checkSubscriptionStatus($club->id,$userData->id);
        $data('subscription') = $subscriptionStatus;
        $data('user') = $userData;
        
        return response()
            ->json((
                'success' => true,
                'data' => $data
            ), 201);

    }
    
    // public function checkSubscriptionStatus($club_id,$user_id)
    // {
    //     $subscriptionDataGet = UserSubscription::where('user_id',$user_id)->where('club_id',$club_id)->first();
    //     if($subscriptionDataGet){
    //         $params('packageName') = $subscriptionDataGet->package_name;
    //         $params('productId') = $subscriptionDataGet->product_id;
    //         $params('purchaseToken') = $subscriptionDataGet->purchase_token;
    //         $setting = Settings::first();
    //         $currentTime = strtotime(date('Y-m-d H:i:s'));
    //         if($setting){
    //             if($setting->expiry_time < $currentTime){
    //                 $refreshToken = $this->refreshAccessToken();
    //             }else{
    //                 $refreshToken('access_token') = $setting->access_token;
    //             }
    //         }else{
    //             $refreshToken = $this->refreshAccessToken();
    //         }
    //         $client = new GuzzleClient();
    //         $response = $client->get("https://www.googleapis.com/androidpublisher/v3/applications/".$params('packageName')."/purchases/subscriptions/".$params('productId')."/tokens/".$params('purchaseToken')."?access_token=".$refreshToken('access_token'));
    //         $response = json_decode($response->getBody(),true);
    //         if(strtotime(date('Y-m-d H:i:s')) > $response('expiryTimeMillis')){
    //             return false;
    //         }else{
    //             return true;
    //         }
    //     }else{
    //         return false;
    //     }
        
    // }

    public function refreshAccessToken()
    {
        $client = new GuzzleClient();
        $response = $client->post("https://accounts.google.com/o/oauth2/token", (
            'form_params' => (
                'grant_type' => 'refresh_token',
                'client_id' => env('GOOGLE_CLIENT_ID'),
                'client_secret' => env('GOOGLE_CLIENT_SECRET_KEY'),
                'refresh_token' => '1//0gz4mxgC29l7LCgYIARAAGBASNwF-L9Ir16-o9khFL_UtL7YYcRK_7nkBmAx2K6-RHpthKQ23atkvC0f01oxWxuCCL7KCe239QbQ'
            )
        ));
        $response = json_decode($response->getBody(),true);
        $setting = Settings::first();
        $currentTime = strtotime(date('Y-m-d H:i:s'));
        $expiry_time = $currentTime + $response('expires_in') - 10;
        if($setting){
            $setting->access_token = $response('access_token');
            $setting->expiry_time = $expiry_time;
            $setting->save();
        }else{
            $data = (
                'access_token' =>  $response('access_token'),
                'refresh_token' =>  '1//0gz4mxgC29l7LCgYIARAAGBASNwF-L9Ir16-o9khFL_UtL7YYcRK_7nkBmAx2K6-RHpthKQ23atkvC0f01oxWxuCCL7KCe239QbQ',
                'expiry_time' =>    $expiry_time
            );
            Settings::Create($data);
        }
        return $response;
    }
    /**
     * Validate Register fields
     *
     * @param Request $request
     * @return IlluminateHttpJsonResponse
     */
    public function validateRegisterFields(Request $request)
    {
        
        if($request->route('slug') == 'clubsaude'){
            // for club clubsaude
            // third party api call for club 
            $curl = curl_init();
            curl_setopt_array($curl, array(
                CURLOPT_URL => "https://clubsaude.nvstec.com/wscrm/Associado/GET_STATUS_ASSOCIADO?cpf=".$request->get('code'),
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => "",
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            ));
            $response = json_decode(curl_exec($curl));
            if($response->status == "Ativo"){
                $cpfData = array('cpf'=>$request->get('code'));
                $validator = $this->userRepository->validateCpfExist($cpfData);
                if ($validator->fails()) {
                    throw new UnauthorizedException('Erro: CPF já existe.');
                }
                return response()->json((
                    'success' => true,
                ), 201);
            }else{
                throw new UnauthorizedException('Erro: CPF não autorizado.');
            }
        }else{
            // for rest of all clubs
            if ($integration = getIntegration($request->route('slug'), 'validateRegisterFields')) {
                return $integration->validateRegisterFields($request);
            }
            $club = $this->clubRepository->findByField('slug', $request->route('slug'))->first();
            $validation = (
                'code' => ('required', new InvitableRule()),
            );

            if ($club->auth === 'secret') {
                $validation = (
                    'code' => ('required', new SecretRule()),
                );
            }

            $validator = Validator::make($request->all(), $validation);

            if ($validator->fails()) {
                throw new ValidationHttpException($validator->errors()->toArray());
            }

            return response()->json((
                'success' => true,
            ), 201);
        }
    }
}

Aonde a request para

Erro no register

Member Accounts and Security Question | Forum Promotion

cli – Error: Call to a member function getUrl() on null PHP UNIT Test Cases Magento 2.X

Please check below PHP Unit Test Case code:

Error Error: Call to a member function getUrl() on null while generating code coverage.

 <?php
    
    namespace VendorModuleTestUnitBlock;
    use MagentoFrameworkTestFrameworkUnitHelperObjectManager;
    use VendorModuleBlockCustomer;
    use MagentoFrameworkUrlInterface;
    
    class CustomerTest extends PHPUnitFrameworkTestCase
    {
        private $objectManager;
    
        protected $urlBuilderMock;

        private $customer;
    
        protected $context;
        
        protected function setUp(): void
        {
            $this->objectManager = new ObjectManager($this);
            
            $this->context = $this->createPartialMock(MagentoFrameworkViewElementTemplateContext::class);
    
            $this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
                ->getMockForAbstractClass();
    
            $this->customer = $this->objectManager->getObject(Customer::class, (
                'context' => $this->context,
                "urlBuilder" => $this->urlBuilderMock
            ));
    
        }
    
    
         public function testGetBaseUrl()
         {
              $url = "testurl";
              $validateData = "test....";
              $this->urlBuilderMock->expects($this->once())->method('getUrl')->with($validateData)->willReturn($url);
              $this->assertEquals($url, $this->customer->getBaseUrl());
         }
    
    }

If anyone understand the issue please reply, Thanks.

c# – Array member set its own index in the array

I’m writing a code where a class member, if != -1, set its own position at array. If the value is == -1, the next free index (whose range is 0 too array’s length) is used. In this review, I’m more interested in the algorithm, making it faster, accurate and readable than anything else. despite I’m using C#, I’d like to keep it simple, C-like and avoid C#’s stuff like Linq, etc. If there’s a readable and faster way to do that without the valueSet flag, would be nice. I just added it because after the swap() call, the swapped elements would be visited twice, with value != -1, making it to be set again, wrongly. Let me know if there’s anything that’s not clear. Below the code with some functions that acts like unittests. Complete different ways to do that are also very welcome.

using System.Collections.Generic;
using System.Diagnostics;

namespace sort
{
    class Program
    {
        static void Main(string() args)
        {
            t1();
            t2();
            t3();
            t4();
        }

        //test case 1
        static void t1()
        {
            var arr = new List<A>();
            arr.Add(new A(-1, "a"));
            arr.Add(new A(-1, "b"));
            arr.Add(new A(0, "c"));
            arr.Add(new A(-1, "d"));

            var sortedArr = doSort(arr.ToArray());
            Debug.Assert(isSorted(sortedArr));
        }

        // test case 2
        static void t2()
        {
            var arr = new List<A>();
            arr.Add(new A(-1, "a"));
            arr.Add(new A(-1, "b"));
            arr.Add(new A(-1, "c"));
            arr.Add(new A(-1, "d"));

            var sortedArr = doSort(arr.ToArray());
            Debug.Assert(isSorted(sortedArr));
        }

        // test case 3
        static void t3()
        {
            var arr = new List<A>();
            arr.Add(new A(0, "a"));
            arr.Add(new A(1, "b"));
            arr.Add(new A(2, "c"));
            arr.Add(new A(3, "d"));

            var sortedArr = doSort(arr.ToArray());
            Debug.Assert(isSorted(arr.ToArray()));
        }

        static void t4()
        {
            var arr = new List<A>();
            arr.Add(new A(-1, "a"));
            arr.Add(new A(1, "b"));
            arr.Add(new A(0, "c"));
            arr.Add(new A(-1, "d"));

            var sortedArr = doSort(arr.ToArray());
            Debug.Assert(isSorted(sortedArr));
        }

        // not meant to be very fast just to be used in the "unittest"
        static bool isSorted(A() arr)
        {
            if(arr.Length == 0)
            {
                return false;
            }

            // this make sure the values is sequential, starting with 0
            // and the last value must be same value as array's length
            if(arr(0).index != 0 || arr(arr.Length - 1).index != arr.Length - 1)
            {
                return false;
            }

            // we have checked already if the first and last values
            // are sequential, no need to recheck here so
            // we loop from 1 to arr.length - 1
            for (int i = 1; i < arr.Length - 1; i++)
            {
                if(i + 1 > arr.Length &&
                  arr(i).index + 1 != arr(i + 1).index)
                {
                    return false;
                }
            }

            return true;
        }

        static A() doSort(A() arr)
        {
            for(int i = 0; i < arr.Length; i++)
            {
                initValue(arr, i);
            }

            return arr;
        }

        static void initValue(A() arr, int i)
        {
            var e = arr(i);

            if(e.valueSet)
            {
                return; /* nothing to do, value initialized already */
            }

            // initialize to current index
            if(e.index == -1)
            {
                e.index = i;
            }
            // an explicit index was set, the value at i index
            // must be set to the value at e.index index
            else if(e.index != i)
            {
                swap(arr, i, e.index);
                // after the swap, that element may be left
                // unitialized. Do initialize now.
                initValue(arr, i);
            }

            e.valueSet = true;
        }

        static void swap(A() arr, int i, int j)
        {
            // swap items
            var t = arr(i);
            arr(i) = arr(j);
            arr(j) = t;

            // update indexes
            arr(i).index = i;
            arr(j).index = j;
        }
    }

    class A
    {
        public A(int i, string s)
        {
            index = i;
            value = s;
        }

        public override string ToString()
        {
            return string.Format("index = %d, value = %s", index, value);
        }

        public int index { get; set; }
        public string value { get; set; }
        public bool valueSet { get; set; }
    }
}

[Liam W] (RIP) Member Self Delete | XenForo Nulled Download

This add-on gives your members the ability to delete their own accounts.

You have the option of setting a ‘cool down period’, during which time access to the board is restricted to a notice that their account is scheduled for deletion – they can cancel deletion before the cool down period ends.

Users are logged out when requesting deletion, and an email confirming them of their decision is sent.

Please consider contributing on GitHub…

.

How do i get all user emails with a special flag (in example member of a Group) for a webform?

i need a Webform that send a email to group of users, which have the same interests. I use “Groups” (not organic groups, because of Drupal9) for that, so the users can decide themself to join or not.

With Webform it is possible to mail to a role of users, but not for groups. Is there a little chance, that i can select only the email-adresses from users with a special flag, like an extra field, or membership in a group ?

German translation: Member search by Andy

Admin submitted a new resource:

German translation: Member search by Andy – deutsche Übersetzung (Gender neutral) für das AddOn: Member search by Andy

This is a german translation (gender neutral) for the AddOn -> Member Search by @AndyB

Read more

.(tagsToTranslate)xenforo(t)xenforo themes(t)xenforo nulled(t)xenforo free(t)xenforo 2.2(t)nulled(t)nulled script(t)whmcs(t)whmcs nulled(t)scripts(t)nulled scripts(t)vbulletin(t)vbulletin nulled(t)vbulletin 5 nulled(t)xenforo resources(t)wordpress download(t)wordpress nulled forum