0

ユーザーがサインアップして自分のプロフィール ページを作成できるサイトがあります。これは、ユーザーがサインアップしたときに投稿を作成することによって行われます。入力されたすべてのフォーム データは、その投稿のさまざまなカスタム フィールドに保存されます。したがって、基本的に、すべてのユーザーには、すべてのプロファイル データを含む 1 つの投稿があります。

各ユーザーは他の人のプロフィールを見ることができます

私はプラグインhttp://www.advancedcustomfields.comを使用しており、具体的にはフロントエンドフォーム機能を使用しています。

ユーザー自身のプロファイルで、フロント エンド フォーム機能を使用して関係フィールド ( http://www.advancedcustomfields.com/resources/field-types/relationship/ ) を表示すると、他のユーザーのプロファイルを選択できるようになります。本質的に友達になること。これはうまくいきます。

私が抱えている問題は、ユーザーが別の人のプロフィールに移動すると、「友達になる」ボタンがあり、クリックすると、そのユーザーのページを現在ログインしているユーザー関係フィールドに追加したいということです。まず、それはできますか?もしそうなら、どのように?

ログインしたユーザーが自分のページにいるときに関係フィールドを現在更新している方法は次のとおりです(ユーザーを追加できるようにするため)。

                    <?php               
                        $activity_information = array(
                        'post_id' => $post->ID, // post id to get field groups from and save data to
                        'field_groups' => array(58), // this will find the field groups for this post (post ID's of the acf post objects)
                        'form_attributes' => array( // attributes will be added to the form element
                        'class' => ''
                        ),
                        'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
                        'html_field_open' => '<div>', // field wrapper open
                        'html_field_close' => '</div>', // field wrapper close
                        'html_before_fields' => '', // html inside form before fields
                        'html_after_fields' => '', // html inside form after fields
                        'submit_value' => 'Update', // value for submit field
                        'updated_message' => '', // default updated message. Can be false to show no message
                        );
                    ?>              
                    <?php acf_form( $activity_information ); ?> 
4

0 に答える 0