Forum Replies Created

Viewing 15 replies - 1 through 15 (of 31 total)
  • Thread Starter ts_hamlet

    (@ts_hamlet)

    Yes the users on this page aren’t authors or anything, they don’t write articles on the site. As it stands, each user has a page that they can edit / are the author of. I’m looking to move away from that and just display a generic page for each user that displays the ACF fields.
    So, if they are the author of their own page, then that should be that issue side-stepped.
    template_include looks promising, but i’m just getting a blank page:

    
    add_filter( 'template_include', 'view-member', 99 );
    function portfolio_page_template( $template ) {
    	if ( is_page( 'archive' )  ) {
    		$new_template = locate_template( array( 'view-member.php' ) );
    		if ( '' != $new_template ) {
    			return $new_template ;
    		}
    	}
    }

    …with the page view-member.php in my child theme root dir. Also note i’m checking if the current page is “archive” (since that’s what it was displaying).

    • This reply was modified 5 years, 3 months ago by ts_hamlet.
    Thread Starter ts_hamlet

    (@ts_hamlet)

    Ok, so i have just this in my child themes functions.php referring to the rewrite:

    add_action('init', 'add_rewrite_member_page');
    function add_rewrite_member_page() {
        add_rewrite_tag('%member%', '([^&]+)', 'member=');
        add_rewrite_rule('^view-member/([^/]*)/?','index.php?member=$matches[1]','top');
    }

    and the file /child-theme/templates/page-view-member.php.

    Using the url mysite.com/view-member/john-doe, i get redirected to the home page.

    I found using index.php?author_name= returned a 404, but using index.php?author= took me to the author archives page – i’m trying to display the custom page in the above templates dir. If easier, i could overwrite the archive page content, but would prefer to display a custom page that just shows the ACF fields.

    Thread Starter ts_hamlet

    (@ts_hamlet)

    So i saw an error in my rewrite rule. The url i’m looking for is mysite.com/view-member/john-doe. My updated rule is:

    add_action('init', 'add_rewrite_member_page');
    function add_rewrite_member_page() {
        add_rewrite_tag('%member%', '([^&]+)', 'member=');
        add_rewrite_rule('^view-member/([^/]*)/([^/]*)/?','index.php?member=$matches[1]&pagename=$matches[2]','top');
    }

    But i’m still getting a (wp) 404 page?

    Thread Starter ts_hamlet

    (@ts_hamlet)

    @jummi1 I’m not sure about the ACF, i have only heard about the plugin from this topic, but reading the documentation it seems they are capable of much more. I am using the free version in my site, but so far i only need quite basic functionality.

    Most of what i learned in this thread has been patiently explained by @bcworkz, but creating a template is as simple as popping one in the page-templates folder of your theme using the naming convention defined in the wp documentation. I haven’t come across a specific ACF template tutorial either, so another hat-tip to bcworkz for explaining how to do this here.

    Thread Starter ts_hamlet

    (@ts_hamlet)

    Ok, so i added the following rewrite in my child theme:

    add_action('init', 'add_rewrite_member_page');
    function add_rewrite_member_page() {
        add_rewrite_tag('%member%', '([^&]+)', 'member=');
        add_rewrite_rule('^goto/([^/]*)/([^/]*)/?','index.php?member=$matches[1]&pagename=$matches[2]','top');
    }

    ..and have gone to the permalinks page, saved (flushed?) it.

    Created a file in my themes page-templates directory called page-view-member.php, with just the following to see if it’s working:

    <?php get_header(); ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php
    					print_r($_GET['member']);
    				?>
    
    				<?php thinkup_input_nav( 'nav-below' ); ?>
    
    				<?php thinkup_input_allowcomments(); ?>
    
    			<?php endwhile; wp_reset_postdata(); ?>
    
    <?php get_footer(); ?>

    …but i’m unsure of the url to load this template?

    Thread Starter ts_hamlet

    (@ts_hamlet)

    Ok, so i want to keep the default “back-end” user profile page, for logged in members to edit their login details and extra ACF fields. But i am looking for another public-facing profile page that just displays to the world only the ACF values.

    The second url schema is what is currently used, and desired. I think it is defined like that in the permalinks?

    Thread Starter ts_hamlet

    (@ts_hamlet)

    Yes that’s working fantastically, thank you for your help so far.

    I just have one issue remaining. This approach seems to work only if there is a page that already exists eg a page called john-doe (parent page: our members). If i enter a non-existent name i get a 404, instead of the logic running through this page and the member not being found. How can i make this dynamic, so that i don’t need / can remove all the actual pages, so that the admin doesn’t need to create a page for each member? And would i link to them like a normal page too?

    Thread Starter ts_hamlet

    (@ts_hamlet)

    Ok, in my page-our-members.php i’ve added the following code:

    
    <?php get_header(); ?>
        <?php while ( have_posts() ) : the_post(); ?>
    	<?php
            	$userSlug =  $wp_query->query_vars['pagename'];
    		$user = get_user_by('slug', $userSlug);
    		print_r($user);
    	?>
    	<?php thinkup_input_nav( 'nav-below' ); ?>
    	<?php thinkup_input_allowcomments(); ?>
    	<?php endwhile; wp_reset_postdata(); ?>
    <?php get_footer(); ?>

    …but the returned user object does not have the field values added by ACF?

    • This reply was modified 5 years, 3 months ago by ts_hamlet.
    Thread Starter ts_hamlet

    (@ts_hamlet)

    I should add – i have already created a template file \my-theme\page-templates\page-our-members.php, but i can’t grab the user info from the url to load the profile info to display. So for example site/view-member/joe-bloggs will show the profile info (added from ACF) in the page, site/view-member/jean-bloggs will show jeans extra profile info etc.

    Thread Starter ts_hamlet

    (@ts_hamlet)

    Yes i agree that my interpretation of the use of the blocks is different from how it is intended, and can see how they can be useful in other scenarios.

    For templating, i found (an outdated) plugin called TinyMCE Templates that provides the functionality i need, although i’m not sure how much longer it will work with wordpress as it is a couple of years old at this date.

    However, i am intrigued by your suggestion:

    Based on your further description of the intended process, I would suggest my “other approach” of placing fields on the user profile form and customizing the post author template to display these fields. Then an admin doesn’t need to bother creating anything for new members. They can go straight to their profile form to add their image and content. You don’t even need a meta box on the profile forms, you hook an action and output the desired fields. Another hook saves the entered data. You can still use the tinyMCE editor for user supplied HTML content.

    If you prefer, a custom fields plugin can manage all that for you, you merely define your fields and alter the theme’s author template. The default URL to the page would be similar to example.info/author/new-user-name/ but the “author” base element can be redefined to be “member” or anything else that works for you.

    This will be easier for uses to edit their info, as it’s all in one place, and less work for the admin to do.
    So i have installed the ACF plugin, added some custom fields to the profile which can be saved and is working well. What i am now looking for is for the member pages to be loaded dynamically? For example, if a viewer browsers to /view-member/member-x, /view-member/member-y it will show a page with member([x|y]) new profile information respectively (not the default wordpress user profile page).

    Thread Starter ts_hamlet

    (@ts_hamlet)

    Ok, lets just run through a use-case to make the blocks aren’t going to cut it, as i’d prefer to use them if possible.
    1). Create a new block consisting of a media block (image and text) and a table. Group them and save them as a resusable block named “MyBlock1”.
    2). In page 1, add MyBlock1 and save the page (without editing the block).
    3). In page 2, add MyBlock1. To add an image, you need to double click the block so it is editable. Add an image from the media library, and some text, save it. Save the page.
    4). View page 1, either in the editor or on the actual site, and the block has been updated with the block contents of page 2.
    Conclusion: Not reusable! The idea of the blocks is great, but it should not over write the original block – i was hoping the block would just be a template that was inserted into the page, or at least have an option of providing a read-only block vs an overwritable block.

    • This reply was modified 5 years, 3 months ago by ts_hamlet.
    Thread Starter ts_hamlet

    (@ts_hamlet)

    Thanks for the reply.
    The site admin is actually creating a page for each user, and then they have the privileges to edit their page only. So the admin is creating the initial page and importing the content block, and at a later stage, the user is adding pictures, blurb etc.
    So just to confirm, is the above not possible with the gutenberg blocks?
    I am using a custom theme, so a custom template is a possibility – will that achieve the above? If the admin just creates the members page, selects the “members” template, then the users will be able to fill it in?
    Can you link to any examples of the above?
    I’d rather just store the content as html than worry about meta boxes etc.

    Thread Starter ts_hamlet

    (@ts_hamlet)

    I should add that the functionality i’m looking for was originally provided by a plugin called Global Content Blocks, that i understand is now depreceated due to security reasons.

    Thread Starter ts_hamlet

    (@ts_hamlet)

    hmmm when i go to that page, i have a select box called Lookup Usergroup, containing Administrators / Newly Registered Users / Bots / Guests / Global Moderators etc.

    Thread Starter ts_hamlet

    (@ts_hamlet)

    Ah, i see they just need the same username. Do they need to have the same password too? Is the hashing of the password different between wp and phpBB?

Viewing 15 replies - 1 through 15 (of 31 total)